Skip to content

chore: upgrade k8s.io/api and controller-runtime to support Kubernetes 1.32 API fields#336

Open
LittleChimera wants to merge 4 commits into
openkruise:masterfrom
LittleChimera:upgrade-k8s-api-v0.32
Open

chore: upgrade k8s.io/api and controller-runtime to support Kubernetes 1.32 API fields#336
LittleChimera wants to merge 4 commits into
openkruise:masterfrom
LittleChimera:upgrade-k8s-api-v0.32

Conversation

@LittleChimera

Copy link
Copy Markdown

Summary

Fixes #335

The webhook was silently dropping Kubernetes API fields introduced after 1.28 (e.g. lifecycle.preStop.sleep / SleepAction introduced GA in 1.30) because it round-tripped Deployment objects through k8s.io/api v0.28 Go structs. Any field not present in the 1.28 struct definition was invisible to the webhook and therefore absent from its mutation patch.

Upgraded modules:

  • k8s.io/api, apimachinery, client-go, apiextensions-apiserver, apiserver, component-base: v0.28.9 → v0.32.3
  • sigs.k8s.io/controller-runtime: v0.16.6 → v0.20.4
  • sigs.k8s.io/gateway-api: v0.8.1 → v1.2.1

Code changes

Required by the API migration in controller-runtime v0.20:

  • source.Kind() is now generic; the event handler is passed inline rather than as a second argument to c.Watch
  • admission.Decoder became an interface (removed pointer indirection on struct fields)
  • Event handler methods use typed event/queue signatures (TypedCreateEvent[client.Object], TypedRateLimitingInterface[reconcile.Request], etc.)
  • HTTPRoute and match-type constants (HeaderMatchRegularExpression, etc.) graduated from v1alpha2/v1beta1 to v1 in gateway-api v1.x

Test fixes:

  • Replaced workqueue.NewRateLimitingQueue with workqueue.NewTypedRateLimitingQueue[reconcile.Request] in unit tests
  • Updated hardcoded ComputeHash digests that changed because PodTemplateSpec gained new zero-value fields in v0.32 (spew serialises the full struct, so new fields shift the FNV-32a digest)

Test plan

  • go build ./... — clean
  • go test ./pkg/... — all pass

🤖 Generated with Claude Code

@kruise-bot kruise-bot requested review from FillZpp and furykerry April 29, 2026 08:00
@kruise-bot

Copy link
Copy Markdown

[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 fillzpp for approval by writing /assign @fillzpp in a comment. For more information see:The Kubernetes 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

@kruise-bot

Copy link
Copy Markdown

Welcome @LittleChimera! It looks like this is your first PR to openkruise/rollouts 🎉

OrangeSnoopy pushed a commit to OrangeSnoopy/rollouts that referenced this pull request May 20, 2026
- test/e2e/rollout_test.go:1785: HeaderMatchRegularExpression moved
  from gatewayv1beta1 to gatewayv1 in gateway-api v1.x; the pkg/ tree
  was already migrated in openkruise#336 but this e2e site was missed
- Makefile CONTROLLER_GEN_VERSION: v0.14.0 -> v0.17.2 to match the
  CRD files committed in openkruise#336 (annotation says v0.17.2); otherwise
  make manifests in CI re-generates with v0.14.0 and the cleanliness
  check `[[ -z $(git status -s) ]]` fails
- Makefile ENVTEST_K8S_VERSION: 1.28.0 -> 1.32.0 to match the
  k8s.io v0.32.3 bump
@OrangeSnoopy

Copy link
Copy Markdown

Hi @LittleChimera , thanks for tackling this upgrade — really useful work. I validated this PR on a fork while preparing some downstream gateway-api changes and found three small fixes that get the GitHub Actions checks green:

  1. test/e2e/rollout_test.go:1785 still references gatewayv1beta1.HeaderMatchRegularExpression. The pkg/... migration in this PR was complete, but this single e2e site was missed — the typecheck error blocks golangci-lint and also prevents the e2e package from compiling.

  2. Makefile: CONTROLLER_GEN_VERSION is still pinned to v0.14.0, but the regenerated CRDs in this PR are annotated controller-gen.kubebuilder.io/version: v0.17.2. CI's cleanliness check ([[ -z $(git status -s) ]] after make manifests) fails because re-running make manifests with v0.14.0 produces a different output than what's committed.

  3. Makefile: ENVTEST_K8S_VERSION should bump from 1.28.0 to 1.32.0 to match the k8s.io v0.32.3 upgrade — otherwise envtest pulls assets for an older Kubernetes version.

Branch with all three fixes on top of this PR's HEAD:
https://github.com/OrangeSnoopy/rollouts/tree/feat/grpcroute-native

GitHub Actions run (golangci-lint + unit-tests both ✅):
https://github.com/OrangeSnoopy/rollouts/actions/runs/26138799141

The fix commit (4 lines changed across 2 files):
OrangeSnoopy@44bc657

Happy to open a separate PR if you'd prefer that workflow, or feel free to cherry-pick directly into this branch — whichever is easier for you. Thanks again for driving the upgrade!

@LittleChimera

Copy link
Copy Markdown
Author

Thanks @OrangeSnoopy — all three fixes applied in 1e22c77:

  1. test/e2e/rollout_test.go:1785 — changed gatewayv1beta1.HeaderMatchRegularExpression to gatewayv1.HeaderMatchRegularExpression (added gatewayv1 import alongside the existing v1beta1 import)
  2. CONTROLLER_GEN_VERSION bumped v0.14.0v0.17.2 to match the committed CRD annotations
  3. ENVTEST_K8S_VERSION bumped 1.28.01.32.0 to match the k8s.io v0.32.3 upgrade

go build ./... and go build ./test/e2e/... both clean locally. CI should be green now.

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.66667% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.25%. Comparing base (b2600e9) to head (1f9b42a).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ler/rollouthistory/rollouthistory_event_handler.go 0.00% 10 Missing ⚠️
pkg/util/rollout_utils.go 0.00% 9 Missing ⚠️
pkg/controller/rollout/rollout_event_handler.go 20.00% 8 Missing ⚠️
.../controller/deployment/deployment_event_handler.go 0.00% 5 Missing ⚠️
pkg/controller/deployment/controller.go 0.00% 4 Missing ⚠️
...troller/batchrelease/batchrelease_event_handler.go 70.00% 3 Missing ⚠️
...controller/batchrelease/batchrelease_controller.go 0.00% 2 Missing ⚠️
pkg/controller/rollout/rollout_controller.go 0.00% 2 Missing ⚠️
...roller/rollouthistory/rollouthistory_controller.go 33.33% 2 Missing ⚠️
...ller/nativedaemonset/nativedaemonset_controller.go 75.00% 0 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #336      +/-   ##
==========================================
- Coverage   51.38%   45.25%   -6.14%     
==========================================
  Files          66       95      +29     
  Lines        8559    10092    +1533     
==========================================
+ Hits         4398     4567     +169     
- Misses       3575     4898    +1323     
- Partials      586      627      +41     
Flag Coverage Δ
unittests 45.25% <21.66%> (-6.14%) ⬇️

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.

LittleChimera and others added 4 commits May 22, 2026 14:37
Fixes openkruise#335 — the webhook was silently dropping fields introduced in
Kubernetes 1.29+ (e.g. lifecycle.preStop.sleep / SleepAction) because
it round-tripped Deployment objects through k8s.io/api v0.28 Go structs,
which do not include those fields.

Upgraded modules:
- k8s.io/api, apimachinery, client-go, apiextensions-apiserver,
  apiserver, component-base: v0.28.9 → v0.32.3
- sigs.k8s.io/controller-runtime: v0.16.6 → v0.20.4
- sigs.k8s.io/gateway-api: v0.8.1 → v1.2.1

Code changes required by the API migration:
- source.Kind() is now generic; handler is passed inline, not to c.Watch
- admission.Decoder is now an interface (drop the pointer indirection)
- Event handler methods use typed event/queue signatures
- HTTPRoute and match-type constants graduated from v1beta1 to v1 in
  gateway-api v1.x
- workqueue.NewTypedRateLimitingQueue used in tests for typed queues
- Test hash constants updated to reflect struct-level changes in v0.32
  (ComputeHash uses spew over the full struct; new zero-value fields in
  PodTemplateSpec change the digest)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Luka Skugor <luka.skugor@chimeramail.com>
- Bump GO_VERSION 1.20 → 1.23 in CI (required by k8s.io/api v0.32 / controller-runtime v0.20)
- Regenerate CRD manifests and RBAC role via make generate manifests
  (new k8s API fields in PodTemplateSpec affect generated output)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Luka Skugor <luka.skugor@chimeramail.com>
- Use gatewayv1.HeaderMatchRegularExpression in e2e test (const removed from v1beta1 in gateway-api v1.x)
- Bump CONTROLLER_GEN_VERSION v0.14.0 → v0.17.2 to match committed CRD annotations
- Bump ENVTEST_K8S_VERSION 1.28.0 → 1.32.0 to match k8s.io v0.32.3 upgrade

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Luka Skugor <luka.skugor@chimeramail.com>
go.mod requires go 1.23.0 (set by the k8s v0.32 upgrade) but the
Dockerfiles used golang:1.20/1.19 which reject 3-part go directives.
All 30 e2e workflow files also had GO_VERSION pinned to 1.20.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Luka Skugor <luka.skugor@chimeramail.com>
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.

Webhook drops unknown Kubernetes API fields (e.g. lifecycle.preStop.sleep) due to outdated k8s.io/api v0.28.9

3 participants