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

DefaultLabelSelector overrides ByObject.Label in DefaultNamespaces #2804

Closed
robbie-demuth opened this issue Apr 30, 2024 · 0 comments · Fixed by #2805
Closed

DefaultLabelSelector overrides ByObject.Label in DefaultNamespaces #2804

robbie-demuth opened this issue Apr 30, 2024 · 0 comments · Fixed by #2805

Comments

@robbie-demuth
Copy link

Prior to #2421, which substituted Namespaces []string for DefaultNamespaces map[string]Config, it used to be possible to combine DefaultLabelSelector, ByObject, and Namespaces like so:

cache.Options{
	Namespaces: []string{"<OPERATOR_NAMESPACE>"},
	DefaultLabelSelector: metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
		MatchLabels: map[string]string{"app.kubernetes.io/name": "appian"},
	}),
	ByObject: map[client.Object]cache.ByObject{
		&apiv1beta1.Appian{}: {
			Label: labels.Everything(),
		},
	},
},

This resulted in the controller's cache only including objects in the <OPERATOR_NAMESPACE> namespace with all Appian custom resources being included and only other resources matching app.kubernetes.io/name=appian being included

The config above is no longer possible. Now, one must do something like so:

cache.Options{
	DefaultNamespaces: map[string]cache.Config{
		"<OPERATOR_NAMESPACE>": {},
	},
	DefaultLabelSelector: metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
		MatchLabels: map[string]string{"app.kubernetes.io/name": "appian"},
	}),
	ByObject: map[client.Object]cache.ByObject{
		&apiv1beta1.Appian{}: {
			Label: labels.Everything(),
		},
	},
},

This however, doesn't result in the same behavior. It still results in the controller's cache only including objects in the <OPERATOR_NAMESPACE> namespace, but the ByObject.Label configuration is ignored, meaning only Appian custom resources matching app.kubernetes.io/name=appian are included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant