Skip to content

refactor: use a spec model for annotation extraction - #1329

Open
lukasmetzner wants to merge 9 commits into
mainfrom
split/core-b-lbspec
Open

refactor: use a spec model for annotation extraction#1329
lukasmetzner wants to merge 9 commits into
mainfrom
split/core-b-lbspec

Conversation

@lukasmetzner

Copy link
Copy Markdown
Contributor

Introduce internal/lbspec, which resolves a Service and the cluster-wide
configuration into a Spec describing the desired state, and which builds the
API opts from it.

  • An invalid annotation now fails the whole reconcile instead of only the
    step that happened to read it. A typo in an HTTP annotation therefore also
    stops node targets from being updated.
  • The remaining 5 hclbServiceOptsBuilder op label values disappear from
    hcloud_ccm_operations_total, and resolveCertificates is added.
  • Certificates are resolved once per Service rather than once per port, and
    on the reconcile context instead of a detached 5s timeout.
  • An empty name annotation no longer tries to rename the Load Balancer to the
    empty string, and an empty hostname annotation no longer publishes an empty
    hostname as the ingress address.
  • private-ipv4 is parsed, so the private network address is compared as an
    address rather than as the literal annotation text.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.51599% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.17%. Comparing base (ec8fd02) to head (9cf4024).

Files with missing lines Patch % Lines
internal/lbspec/opts.go 62.80% 45 Missing ⚠️
internal/hcops/load_balancer.go 80.55% 13 Missing and 8 partials ⚠️
internal/testsupport/klog.go 0.00% 11 Missing ⚠️
hcloud/load_balancers.go 91.48% 3 Missing and 1 partial ⚠️
internal/hcops/mocks.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1329      +/-   ##
==========================================
- Coverage   70.11%   69.17%   -0.94%     
==========================================
  Files          29       32       +3     
  Lines        2794     2667     -127     
==========================================
- Hits         1959     1845     -114     
- Misses        643      658      +15     
+ Partials      192      164      -28     
Flag Coverage Δ
e2e 46.17% <57.86%> (+1.07%) ⬆️
unit 64.79% <77.18%> (-1.71%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Base automatically changed from split/core-a-typed-annotations to main August 26, 2026 13:19
Introduce internal/lbspec, which resolves a Service and the cluster-wide
configuration into a Spec describing the desired state, and which builds the
API opts from it.

- An invalid annotation now fails the whole reconcilement instead of only the
step that happened to read it. A typo in an HTTP annotation therefore also
stops node targets from being updated.
- The remaining 5 hclbServiceOptsBuilder op label values disappear from
hcloud_ccm_operations_total, and resolveCertificates is added.
- Certificates are resolved once per Service rather than once per port, and
on the reconcile context instead of a detached 5s timeout.
- An empty name annotation no longer tries to rename the Load Balancer to the
empty string, and an empty hostname annotation no longer publishes an empty
hostname as the ingress address.
- private-ipv4 is parsed, so the private network address is compared as an
address rather than as the literal annotation text.
@lukasmetzner

Copy link
Copy Markdown
Contributor Author

Kubernetes events example for a Service object:

  Normal   EnsuringLoadBalancer           2s (x3 over 17s)   service-controller               Ensuring load balancer
  Warning  InvalidLoadBalancerAnnotation  2s (x3 over 17s)   hcloud-cloud-controller-manager  Invalid Load Balancer annotation "load-balancer.hetzner.cloud/use-private-ip": strconv.ParseBool: parsing "123": invalid syntax
  Warning  InvalidLoadBalancerAnnotation  2s (x3 over 17s)   hcloud-cloud-controller-manager  Invalid Load Balancer annotation "load-balancer.hetzner.cloud/protocol": invalid protocol: httpl
  Warning  SyncLoadBalancerFailed         2s (x3 over 17s)   service-controller               Error syncing load balancer: failed to ensure load balancer: hcloud/loadBalancers.EnsureLoadBalancer: 2 Load Balancer annotation(s) are invalid

@lukasmetzner
lukasmetzner marked this pull request as ready for review August 27, 2026 10:57
@lukasmetzner
lukasmetzner requested a review from a team as a code owner August 27, 2026 10:57
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.

1 participant