Skip to content

[fix] trim whitespace and skip empty entries in linode-loadbalancer-tags - #654

Merged
komer3 merged 1 commit into
linode:mainfrom
lbarrosby:fix/nodebalancer-tags-whitespace
Nov 6, 2026
Merged

komer3 merged 1 commit into
linode:mainfrom
lbarrosby:fix/nodebalancer-tags-whitespace

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

service.beta.kubernetes.io/linode-loadbalancer-tags is split on commas without trimming, so a value written like the other list annotations, "production, web-tier", sends " web-tier" (leading space) to the NodeBalancer API, and a trailing or doubled comma ("production,,web-tier,") sends an empty tag. The same list is compared with reflect.DeepEqual against nb.Tags in updateNodeBalancer, so the values stored by the API and the desired list can disagree on every sync.

GetLoadBalancerTags now trims each entry and skips empty ones. Values that were already clean ("fake,test,yolo") produce the same list as before.

Tests: added Test_loadbalancers_GetLoadBalancerTags (no annotation, plain list, spaces after commas, empty entries, empty annotation). The last three fail on master and pass with the change. go test ./cloud/... and golangci-lint run -c .golangci.yml ./cloud/linode/ are clean.

General:

  • Have you removed all sensitive information, including but not limited to access keys and passwords?
  • Have you checked to ensure there aren't other open or closed Pull Requests for the same bug/feature/question?

Pull Request Guidelines:

  1. Does your submission pass tests?
  2. Have you added tests?
  3. Are you addressing a single feature in this PR?
  4. Are your commits atomic, addressing one change per commit?
  5. Are you following the conventions of the language?
  6. Have you saved your large formatting changes for a different PR, so we can focus on your work?
  7. Have you explained your rationale for why this feature is needed?
  8. Have you linked your PR to an open issue

The tags annotation was split on commas as is, so "production, web-tier"
sent " web-tier" to the API and a trailing comma sent an empty tag.
Trim each entry and drop the empty ones.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@lbarrosby
lbarrosby requested review from a team as code owners November 6, 2026 02:12
@github-actions github-actions Bot added the bugfix for any bug fixes in the changelog. label Nov 6, 2026

@komer3 komer3 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 contribution :)

@komer3
komer3 enabled auto-merge (squash) November 6, 2026 15:23
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.65%. Comparing base (1143441) to head (69cf572).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
+ Coverage   82.64%   82.65%   +0.01%     
==========================================
  Files          19       19              
  Lines        2616     2618       +2     
==========================================
+ Hits         2162     2164       +2     
  Misses        454      454              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@komer3
komer3 merged commit de3e6dd into linode:main Nov 6, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix for any bug fixes in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants