-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Index metadata.name for cluster-name label #740
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,10 @@ func newReconciler(mgr manager.Manager, actuator Actuator) reconcile.Reconciler | |
actuator: actuator, | ||
} | ||
|
||
mgr.GetFieldIndexer().IndexField(&clusterv1.Cluster{}, "metadata.name", func(obj runtime.Object) []string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is another option to filter cluster object by using
have you considered this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem that I see using labels is that it doesn't guarantee uniqueness and if we duplicate the name there we'd need to keep it in sync, which isn't ideal |
||
return []string{obj.(*clusterv1.Cluster).Name} | ||
}) | ||
|
||
if r.nodeName == "" { | ||
klog.Warningf("environment variable %v is not set, this controller will not protect against deleting its own machine", NodeNameEnvVar) | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
Does it matter that IndexerFunc is meant to be unique across namespaces?
cluster-api/vendor/sigs.k8s.io/controller-runtime/pkg/client/interfaces.go
Lines 91 to 93 in 0617f27
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 believe that's taken care of in this wrapper
cluster-api/vendor/sigs.k8s.io/controller-runtime/pkg/cache/informer_cache.go
Lines 133 to 178 in 0617f27
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.
@vincepri From the looks of it, that field indexes both the namespaced and non-namespaced keys for each value, so wouldn't there be a collision for the non-namespaced value of two clusters with the same name in different namespaces?