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

Add GetLabelSelector utility function #606

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

fmount
Copy link
Contributor

@fmount fmount commented Feb 26, 2025

This function is used as utility to get the list of matchLabels used as selector for Deployments and StatefulSet. Most of the service operators use to pass a serviceLabels map[string]string, which is available in the controller(s). This function translates the data structure into a metav1.LabelSelector that we can easily plug to the existing ensureTopology logic provided by infra-operator [1].

[1] https://github.com/openstack-k8s-operators/infra-operator/blob/main/apis/topology/v1beta1/topology_types.go#L126

@fmount
Copy link
Contributor Author

fmount commented Feb 26, 2025

@olliewalsh @stuggi this is Glance [1] and it might really result in a quick update across the operators that is worth doing before the freeze. I analyzed the context a bit (see [2]) and we could do this and replace all the calls that get a Single label (service, component or anything else) with:

labels.GetLabelSelector(serviceLabels)
as I did in [3]. Let's discuss and have some feedback and decide what to do. I have already a bunch of patches that I might just need to propose, but let's first agree on the pattern.

[1] https://paste.opendev.org/show/bc3Zd04FEd2E7rEUZPdn/
[2] https://paste.opendev.org/show/bpJJisuGag3C9GQMkFrX/
[3] openstack-k8s-operators/glance-operator#693

This function is used as utility to get the list of "matchLabels" used
as selector for Deployments and StatefulSet. Most of the service
operators use to pass a "serviceLabels map[string]string", which is
available in the controller(s). This function translates the data
structure into a metav1.LabelSelector that we can easily plug to the
existing ensureTopology logic provided by infra-operator [1].

[1] https://github.com/openstack-k8s-operators/infra-operator/blob/main/apis/topology/v1beta1/topology_types.go#L126

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
Copy link
Contributor

@stuggi stuggi left a comment

Choose a reason for hiding this comment

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

/lgtm

@stuggi stuggi merged commit 4046ee8 into openstack-k8s-operators:main Feb 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants