Skip to content

feat: add support for load balancer, listener, and pool tags annotations#3058

Open
A10ss wants to merge 3 commits into
kubernetes:masterfrom
A10ss:support-add-tags-to-lb
Open

feat: add support for load balancer, listener, and pool tags annotations#3058
A10ss wants to merge 3 commits into
kubernetes:masterfrom
A10ss:support-add-tags-to-lb

Conversation

@A10ss

@A10ss A10ss commented Jan 23, 2026

Copy link
Copy Markdown

What this PR does / why we need it:
This PR adds support for the add tags to load balancer, listener, and pool via the service annotations in cloud-provider-openstack (OCCM).

Which issue this PR fixes(if applicable):
fixes #3032 #2327

Special notes for reviewers:
You can add annotations to the service like:

loadbalancer.openstack.org/listener-tags: '["tags-test"]'
loadbalancer.openstack.org/load-balancer-tags: '["tags-test"]'
loadbalancer.openstack.org/pool-tags: '["tags-test"]'

Then check if the tags have been added to the service's load blancer(the service's type should be load balancer)

Release note:

[openstack-cloud-controller-manager] Support adding tags to load balancers, listeners, and pools via Service annotations.

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 23, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jan 23, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign anguslees for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @A10ss!

It looks like this is your first PR to kubernetes/cloud-provider-openstack 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/cloud-provider-openstack has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 23, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @A10ss. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 23, 2026
@A10ss
A10ss force-pushed the support-add-tags-to-lb branch from b9d7293 to 6da530f Compare January 23, 2026 07:37
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 23, 2026
@kayrus

kayrus commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 23, 2026

@kayrus kayrus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. See my initial comments.

Comment thread pkg/openstack/loadbalancer.go Outdated
var desiredTags []string
if len(svcConf.lbTags) == 0 {
klog.V(4).Infof("No load balancer tags found from service annotation key: %s", ServiceAnnotationLoadBalancerTags)
} else if err := json.Unmarshal([]byte(svcConf.lbTags), &desiredTags); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like an idea to use json inside the annotation. Can you make it simpler? See an example

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep, the json format could support more complex tags, and for LB tags we may don't need very complex tags, so I think your point is right, I'll change it.

Comment thread pkg/openstack/loadbalancer.go Outdated
Comment on lines +976 to +977
} else {
if svcConf.supportLBTags {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logic feels a bit hard to follow with the nested if statements. Would it be possible to simplify or refactor it to improve readability? The same applies to other parts of new code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agree with that, I'd like to do.

@A10ss

A10ss commented Jan 27, 2026

Copy link
Copy Markdown
Author

@kayrus please help review this PR again, thanks!

@A10ss
A10ss requested a review from kayrus January 27, 2026 05:28
@Garfield96

Copy link
Copy Markdown

@A10ss Thanks for the PR. We are also very interested in this feature.

@kayrus, @dulek Could you please help review this PR? Thanks

@Garfield96

Copy link
Copy Markdown

Hi @kayrus,
just a gentle ping on this one! Thanks for your time!

@k8s-triage-robot

Copy link
Copy Markdown

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@kubernetes-prow kubernetes-prow Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 6, 2026
@alexanderstephan

Copy link
Copy Markdown

Hi @kayrus, Any updates on this? Thx!

@kayrus

kayrus commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Hi. Apologies for the late response. Please update the initial PR message with a new tags format and add a documentation.

Thinking out loud: this follows the spaghetti code style I'd like us to move away from in future (see #3076). I know this isn't your decision. The overall OCCM code style encourages contributors to develop patches this way. I believe at some point we'll tackle a code refactoring, and unit tests would help tremendously with that. Therefore, please add unit tests to this PR as well.

@Garfield96

Copy link
Copy Markdown

@A10ss Can you include the requested changes by @kayrus, or shall @alexanderstephan or me take care of it? If we don't hear back from you until 20. July 2026, we will fork the PR and add the requested changes.

@yahor-kurachkin yahor-kurachkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I left a few stylistic suggestions. Other than that, it looks good to me. As kayrus mentioned, it also makes sense to add unit tests.


// mergeTags merges existedTags and desiredTags, returns true if all desiredTags are in existedTags.
func mergeTags(existedTags []string, desiredTags []string) (bool, []string) {
if len(existedTags) == 0 || existedTags == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

existedTags == nil is unreachable because len(existedTags) returns 0 even for nil slice.

Suggested change
if len(existedTags) == 0 || existedTags == nil {
if len(existedTags) == 0 {

Comment on lines +219 to +221
} else {
return false, tagSet.Union(desiredTagsSet).List()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
} else {
return false, tagSet.Union(desiredTagsSet).List()
}
}
return false, tagSet.Union(desiredTagsSet).List()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The else block in the end of the function is redundant and can be removed.

Comment on lines +262 to +267
var desiredTags []string
if len(svcConf.lbTags) == 0 {
klog.V(4).Infof("No load balancer tags found from service annotation key: %s", ServiceAnnotationLoadBalancerTags)
} else {
desiredTags = cpoutil.SplitTrim(svcConf.lbTags, ',')
}

@yahor-kurachkin yahor-kurachkin Jul 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a big deal, but I think this version is a bit cleaner. SplitTrim works fine with empty strings. And this block of code is repeated several times.

Suggested change
var desiredTags []string
if len(svcConf.lbTags) == 0 {
klog.V(4).Infof("No load balancer tags found from service annotation key: %s", ServiceAnnotationLoadBalancerTags)
} else {
desiredTags = cpoutil.SplitTrim(svcConf.lbTags, ',')
}
desiredTags := cpoutil.SplitTrim(svcConf.lbTags, ',')
if len(desiredTags) == 0 {
klog.V(4).Infof("No load balancer tags found from service annotation key: %s", ServiceAnnotationLoadBalancerTags)
}

@alexanderstephan

Copy link
Copy Markdown

Hi @yahor-kurachkin, I integrated the review in #3149. Please take a look there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hope OCCM could support add tags to LB, listeners, pools

7 participants