-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
|
||
func localClusterNamespace(ns string) string { | ||
if ns == "" { | ||
return "local" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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.