Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Cache: Allow defining options that apply to all namespaces that themselves have no explicit config #2528

Merged
merged 1 commit into from Oct 8, 2023

Conversation

alvaroaleman
Copy link
Member

This change allows to define a cache selector config that applies to all namespaces that themselves do not have an explicit config. An example would be "Cache all namespaces without selector, except for namespace foo, there use labelSelector bar=baz".

More as a side effect than intentionally, this also makes it valid to use the empty string as a key in the Namespaces and byObject.Namespaces config of the cache. This is very useful to for example have a namespace CLI flag that might be empty.

This change is the last missing bit to finish the implementation of the cache options design doc.

Sidenote: If someone can come up with a less wordy title that describes what this does, that would be nice :)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 8, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 8, 2023
@@ -172,6 +178,11 @@ type Options struct {
// the namespaces in here will be watched and it will by used to default
// ByObject.Namespaces for all objects if that is nil.
//
// It is possible to have specific Config for just some namespaces
// but cache all namespaces by using the AllNamespaces const as the map key.
// This wil then include all namespaces that do not have a more specific
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
// This wil then include all namespaces that do not have a more specific
// This will then include all namespaces that do not have a more specific

@@ -220,6 +231,11 @@ type ByObject struct {
// Settings in the map value that are unset will be defaulted.
// Use an empty value for the specific setting to prevent that.
//
// It is possible to have specific Config for just some namespaces
// but cache all namespaces by using the AllNamespaces const as the map key.
// This wil then include all namespaces that do not have a more specific
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
// This wil then include all namespaces that do not have a more specific
// This will then include all namespaces that do not have a more specific

…mselves have no explicit config

This change allows to define a cache selector config that applies to all
namespaces that themselves do not have an explicit config. An example
would be "Cache all namespaces without selector, except for namespace
foo, there use labelSelector bar=baz".

More as a side effect than intentionally, this also makes it valid to use
the empty string as a key in the `Namespaces` and `byObject.Namespaces`
config of the cache. This is very useful to for example have a
`namespace` CLI flag that might be empty.

This change is the last missing bit to finish the implementation of the
[cache options design doc](./designs/cache_options.md).
@troy0820
Copy link
Member

troy0820 commented Oct 8, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2023
@k8s-ci-robot k8s-ci-robot merged commit 968daa8 into main Oct 8, 2023
9 checks passed
@alvaroaleman
Copy link
Member Author

/cherrypick release-0.16

@k8s-infra-cherrypick-robot

@alvaroaleman: new pull request created: #2539

In response to this:

/cherrypick release-0.16

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sbueringer
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants