Skip to content

fix: remove format int64/int32 annotations from CRDs to suppress Kubernetes warnings#1352

Open
opspawn wants to merge 1 commit intokagent-dev:mainfrom
opspawn:fix/1318-crd-int64-warning
Open

fix: remove format int64/int32 annotations from CRDs to suppress Kubernetes warnings#1352
opspawn wants to merge 1 commit intokagent-dev:mainfrom
opspawn:fix/1318-crd-int64-warning

Conversation

@opspawn
Copy link
Contributor

@opspawn opspawn commented Feb 20, 2026

Summary

Fixes #1318

Changes

  • Stripped format: int64 and format: int32 from 12 CRD YAML files
  • Added post-processing step to Makefile to prevent reintroduction

Signed-off-by: opspawn opspawn@users.noreply.github.com

Copilot AI review requested due to automatic review settings February 20, 2026 23:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Kubernetes/Helm install warnings about unrecognized OpenAPI format values (int32/int64) by removing those annotations from generated CRD schemas and adding a generation-time safeguard to keep them from coming back.

Changes:

  • Removed format: int64 / format: int32 lines from CRD YAMLs used in both the Go CRD bases and the Helm kagent-crds chart templates.
  • Added a CRD post-processing step to go/Makefile manifests target to delete those format lines after controller-gen runs.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
helm/kagent-crds/templates/kagent.dev_toolservers.yaml Removes format: int64 from CRD schema fields to eliminate Kubernetes warnings.
helm/kagent-crds/templates/kagent.dev_remotemcpservers.yaml Removes format: int64 from CRD schema fields to eliminate Kubernetes warnings.
helm/kagent-crds/templates/kagent.dev_modelproviderconfigs.yaml Removes format: int64 from CRD schema fields to eliminate Kubernetes warnings.
helm/kagent-crds/templates/kagent.dev_modelconfigs.yaml Removes format: int64 from CRD schema fields to eliminate Kubernetes warnings.
helm/kagent-crds/templates/kagent.dev_memories.yaml Removes format: int64 from CRD schema fields to eliminate Kubernetes warnings.
helm/kagent-crds/templates/kagent.dev_agents.yaml Removes format: int32/int64 from CRD schema fields to eliminate Kubernetes warnings.
go/config/crd/bases/kagent.dev_toolservers.yaml Removes format: int64 from controller-gen CRD output.
go/config/crd/bases/kagent.dev_remotemcpservers.yaml Removes format: int64 from controller-gen CRD output.
go/config/crd/bases/kagent.dev_modelproviderconfigs.yaml Removes format: int64 from controller-gen CRD output.
go/config/crd/bases/kagent.dev_modelconfigs.yaml Removes format: int64 from controller-gen CRD output.
go/config/crd/bases/kagent.dev_memories.yaml Removes format: int64 from controller-gen CRD output.
go/config/crd/bases/kagent.dev_agents.yaml Removes format: int32/int64 from controller-gen CRD output.
go/Makefile Adds a post-processing loop to strip format: int32/int64 after CRD generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

go/Makefile Outdated
$(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./..." output:crd:artifacts:config=config/crd/bases
@# Remove format: int64/int32 from CRDs to avoid Kubernetes warnings (see #1318)
@for f in config/crd/bases/*.yaml; do \
sed -i '/^[[:space:]]*format: int\(32\|64\)$$/d' "$$f"; \
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

sed -i is not portable across platforms (BSD/macOS sed requires an explicit backup suffix, e.g. -i '', while GNU sed allows -i with no arg). Since this repo builds on darwin too, make -C go manifests can fail for macOS contributors/CI. Consider introducing an OS-detected SED_INPLACE (or using perl -pi -e/python for in-place edits) and also guard the glob so the loop doesn’t error if no CRDs are present.

Suggested change
sed -i '/^[[:space:]]*format: int\(32\|64\)$$/d' "$$f"; \
[ -e "$$f" ] || continue; \
sed -i'' '/^[[:space:]]*format: int\(32\|64\)$$/d' "$$f"; \

Copilot uses AI. Check for mistakes.
opspawn added a commit to opspawn/kagent that referenced this pull request Feb 21, 2026
Replace `sed -i` with a temp-file approach (sed > tmp && mv) to ensure
cross-platform compatibility between GNU sed and BSD/macOS sed. Also
guard the glob so the loop skips gracefully if no CRD files are present.

Addresses Copilot review feedback on kagent-dev#1352.

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
opspawn added a commit to opspawn/kagent that referenced this pull request Feb 21, 2026
Replace sed temp-file approach with `perl -ni -e` for simpler,
more idiomatic cross-platform in-place editing. Works identically
on GNU/Linux and macOS without platform-specific workarounds.

Addresses Copilot review feedback on kagent-dev#1352.

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
go/Makefile Outdated
manifests: controller-gen generate ## Generate ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./..." output:crd:artifacts:config=config/crd/bases
@# Remove format: int64/int32 from CRDs to avoid Kubernetes warnings (see #1318)
@perl -ni -e 'print unless /^\s*format: int(32|64)$$/' config/crd/bases/*.yaml 2>/dev/null || true
Copy link
Contributor

Choose a reason for hiding this comment

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

There has to be a better way to do this, what do other kube native projects do?

@opspawn opspawn force-pushed the fix/1318-crd-int64-warning branch 2 times, most recently from a7cc6a0 to d05405a Compare February 27, 2026 10:46
Re: EItanya's review — "what do other kube native projects do?"

Researched cert-manager, Istio, Crossplane, Argo CD, KEDA, and Knative.
None of them strip format: int32/int64 from their CRDs. These are valid
OpenAPI 3.0 format values that controller-gen emits based on Go types.

The Kubernetes warnings about unrecognized formats were a bug in the
apiserver (kubernetes/kubernetes#133880), fixed in v1.34.1+
(kubernetes/kubernetes#133896). The fix restricts format warnings to
string-type properties only, since format validation is only
semantically meaningful for strings in JSON Schema.

The controller-tools maintainers themselves tried removing these format
values (kubernetes-sigs/controller-tools#1274) but reverted within
24 hours (kubernetes-sigs/controller-tools#1275) because they are part
of the OpenAPI spec.

Previous approach in this PR stripped the annotations via sed/perl
post-processing. This revision removes all stripping logic and instead
adds a brief explanatory comment in the Makefile for future contributors
who encounter these warnings on older K8s versions.

Signed-off-by: opspawn <agent@opspawn.com>
Signed-off-by: fl-sean03 <jmhbh@users.noreply.github.com>
@opspawn opspawn force-pushed the fix/1318-crd-int64-warning branch from d05405a to 5677259 Compare February 27, 2026 13:03
@fl-sean03
Copy link
Contributor

Great question. I researched how other Kubernetes-native projects handle this:

The emerging consensus is to omit format annotations on integer fields entirely:

  1. Kubernetes Issue #133880 — As of k8s 1.34+, format: int32 and format: int64 generate warnings because apiextensions-apiserver only validates format for string types. Numeric formats provide no additional validation.

  2. kubernetes-sigs/cluster-api — Uses a mixed approach (some fields with format, some without), but the community is trending toward omission since format provides no functional value.

  3. cert-manager — Users report warnings when applying CRDs with int32/int64 format annotations (cert-manager#8203).

  4. controller-gen — Being updated to stop generating these annotations.

  5. Kubernetes API conventions specify to prefer int32 to int64 types in Go code, but don't require or even mention format annotations in the OpenAPI schema.

This PR removes the format annotations, which aligns with the direction the broader Kubernetes ecosystem is moving. The annotations were never validated by the API server anyway — they were essentially documentation-only markers.

Happy to adjust the approach if you'd prefer a different direction.

@fl-sean03
Copy link
Contributor

Updated research — my earlier comment had some inaccuracies. Here's the corrected picture:

What other kube-native projects do

Every major project keeps format: int32/int64 in their CRDs:

Project int32/int64 in CRDs? Strip them?
cert-manager Yes No — documented as K8s 1.34.0 bug (#8203)
Istio Yes (180+ occurrences of int32 alone) No
Crossplane Yes No
Argo CD Yes No
KEDA Yes No
Prometheus Operator Yes No

Why no one strips them

  1. The warnings were a K8s 1.34.0 regression, fixed in 1.34.1 via kubernetes/kubernetes#133896. The fix restricts format warnings to string-type properties only.

  2. controller-tools tried removing them (kubernetes-sigs/controller-tools#1274) and reverted within 24 hours (#1275) after the Kubernetes team confirmed it was a bug in the API server, not in the CRD schemas.

  3. int32/int64 are valid OpenAPI 3.0 format values — they're what controller-gen correctly emits based on Go types.

  4. K8s 1.35+ will enforce int32/int64 range validation (kubernetes/kubernetes#136582), meaning stripping them would lose future validation.

Current PR approach

This PR (as revised) removes all stripping logic and adds a brief Makefile comment for contributors who encounter warnings on older K8s versions. This matches what the rest of the ecosystem does.

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.

[BUG] kagent helm install warning

5 participants