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

Fix multi-namespace watches and add a test #339

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Fix multi-namespace watches and add a test #339

merged 1 commit into from
Nov 12, 2024

Conversation

ecordell
Copy link
Contributor

@ecordell ecordell commented Nov 8, 2024

The existing implementation didn't wire up the caches correctly if more than one namespace was specified. Caches are identified by the namespace they watch, so we need to construct lookup keys per-watched namespace.

This also adds a test of the namespace watch modes.

@ecordell ecordell marked this pull request as ready for review November 8, 2024 21:37
@ecordell ecordell requested a review from a team November 8, 2024 21:37

func localClusterNamespace(ns string) string {
if ns == "" {
return "local"
Copy link
Member

Choose a reason for hiding this comment

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

Where does this come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just a part of the key used to locate the right cache. I use "local" as a convention because it's part of the same cluster the controller is running on, and controllers can also start watches of remote clusters.

}
for _, cluster := range clusters {
c.enqueue(v1alpha1ClusterGVR, cluster)
for _, ns := range c.namespaces {
Copy link
Member

Choose a reason for hiding this comment

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

if the namespace list is empty, where does it get watched then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

namespaces gets defaulted to []string{corev1.AllNamespace} (which is just the empty string) if it is empty on startup.

the existing implementation didn't wire up the caches correctly. this
also adds a test of the namespace watch modes.
Copy link

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

I had @ecordell walk me through this one and it looks good from my perspective

@ecordell ecordell added this pull request to the merge queue Nov 12, 2024
Merged via the queue into main with commit 9ef69f8 Nov 12, 2024
11 checks passed
@ecordell ecordell deleted the nstest branch November 12, 2024 20:39
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants