Skip to content

fix(api): correct LocalASN OpenAPI format to int64 - #3054

Merged
fedepaol merged 1 commit into
metallb:mainfrom
lexfrei:fix/bgppeer-localasn-int64
May 27, 2026
Merged

fedepaol merged 1 commit into
metallb:mainfrom
lexfrei:fix/bgppeer-localasn-int64

Conversation

@lexfrei

@lexfrei lexfrei commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Is this a BUG FIX or a FEATURE ?:

/kind bug

What this PR does / why we need it:

BGPPeer.spec.localASN (added in v0.16.0) declares +kubebuilder:validation:Maximum=4294967295 but no Format annotation. controller-gen therefore emits format: int32 in the generated CRD, which is internally inconsistent: int32's maximum is 2,147,483,647 — the schema's declared maximum (4,294,967,295) exceeds it.

The sibling fields ASN (peerASN) and MyASN on the same struct already carry +kubebuilder:validation:Format=int64 for the same uint32 Go type and the same Maximum. This PR aligns LocalASN with them.

Diff scope:

  • api/v1beta2/bgppeer_types.go: one added annotation line (matches sibling-field pattern).
  • config/crd/bases/metallb.io_bgppeers.yaml, charts/metallb/charts/crds/templates/crds.yaml, six config/manifests/metallb-*.yaml: regenerated by inv generatemanifests, each file changes a single format: int32 → format: int64 line for the localASN property.

No runtime change — internal Go types for LocalASN are already uint32 end-to-end. Schema-only fix.

Special notes for your reviewer:

Reproduce the regeneration with Python invoke and the deps from tasks.py:

inv generatemanifests

Release note:

Fixed BGPPeer v1beta2 schema: `localASN` now correctly declares `format: int64` (was `int32`, which cannot represent the declared `Maximum=4294967295`).

@lexfrei
lexfrei requested review from fedepaol and oribon as code owners May 20, 2026 23:52

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the validation format for the LocalASN field in the BGPPeer CRD from int32 to int64 across the Go type definitions, Helm charts, and generated manifests. This ensures that the full range of a uint32 (up to 4294967295) is correctly handled by the Kubernetes API validation, as the previous int32 format was insufficient. I have no feedback to provide as there were no review comments.

The BGPPeer v1beta2 spec declared LocalASN with the kubebuilder annotation
`+kubebuilder:validation:Maximum=4294967295` but no `Format` annotation, so
controller-gen emitted `format: int32` in the generated CRD. int32 cannot
represent 4,294,967,295 (its maximum is 2,147,483,647), so the schema is
internally inconsistent.

The sibling fields `ASN` (peerASN) and `MyASN` already carry
`+kubebuilder:validation:Format=int64` for the same uint32 type with the same
maximum. Align LocalASN with them: a one-line annotation addition + the
matching controller-gen regeneration of the CRDs and the all-in-one
manifests.

Found during downstream consumer review while bumping cozystack to
MetalLB v0.16.0; see cozystack/cozystack#2699 for the trigger context.

Signed-off-by: Aleksei Sviridkin <[email protected]>
@lexfrei
lexfrei force-pushed the fix/bgppeer-localasn-int64 branch from 21c03d2 to 4fbaf0f Compare May 21, 2026 10:17
@fedepaol
fedepaol merged commit a148280 into metallb:main May 27, 2026
28 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants