⚠️ Upgrade controller-runtime from v0.22.4 to v0.23.0#5378
Conversation
5ff681b to
5d1a725
Compare
fc97a79 to
ca77b70
Compare
There was a problem hiding this comment.
Pull request overview
This PR upgrades controller-runtime from v0.22.4 to v0.23.0, introducing breaking changes for type-safe webhook APIs using generics and migrating to the new Events API. The changes update all webhook scaffolding, templates, and testdata projects to use the new APIs while maintaining backward compatibility through legacy path support.
Changes:
- Webhook API migration to type-safe generics, removing runtime.Object type assertions and interface checks
- Events API migration from k8s.io/client-go/tools/record to k8s.io/client-go/tools/events with updated RBAC permissions
- Test suite improvements using Eventually pattern for graceful webhook server shutdown
Reviewed changes
Copilot reviewed 89 out of 99 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugins/golang/v4/scaffolds/init.go | Updates ControllerRuntimeVersion constant to v0.23.0 |
| pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/*.go | Updates webhook templates with type-safe generics and removes type assertions |
| pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go | Migrates to new Events API with updated RBAC and Eventf signature |
| testdata/project-v4*/*_webhook.go | Updates all webhook implementations to use type-safe generics |
| testdata/project-v4*/webhook_suite_test.go | Adds Eventually pattern for graceful test environment shutdown |
| testdata/project-v4*/*_controller.go | Updates controller-runtime documentation URLs and Events API usage |
| testdata/project-v4*/go.mod | Upgrades controller-runtime to v0.23.0 and related dependencies |
| testdata/project-v4*/config/rbac/role.yaml | Updates RBAC from core to events.k8s.io API group |
| test/e2e/utils/webhooks.go | Updates test utilities to use generic object parameter naming |
| cmd/version.go | Updates kubernetesVendorVersion to 1.35.0 |
| build/.goreleaser.yml | Updates KUBERNETES_VERSION to 1.35.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ca77b70 to
408eb3b
Compare
be84d25 to
f250e7b
Compare
|
Hi @camilamacedo86 shouldn't we change the implementation in testdata and documentation as well? See: https://github.com/search?q=repo%3Acamilamacedo86%2Fkubebuilder+obj.%28*&type=code |
v0.22.4 to v0.23.0v0.22.4 to v0.23.0 and add support to k8s 1.35
f250e7b to
692b651
Compare
|
Thank you a lot for your help. Could you please give a look and help us with this one for we are able to unblock the release? |
v0.22.4 to v0.23.0 and add support to k8s 1.35v0.22.4 to v0.23.0
|
/override APIDiff (ignore it) |
This comment was marked as resolved.
This comment was marked as resolved.
|
/test pull-kubebuilder-e2e-k8s-1-34-0 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, vitorfloriano The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
5391809
into
kubernetes-sigs:master
Controller-Runtime v0.23.0 Breaking Changes
Description
Bump
controller-runtimeto v0.23.0.controller-runtimev0.23.0 introduces breaking changes including type-safe webhook APIs, new events API, and test environment teardown improvements. This PR updates Kubebuilder's scaffolding/templates to match the new APIs, while keeping legacy scaffolding working.Release notes: https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.23.0
Breaking Changes Summary
controller-runtime v0.23.0 introduced three major breaking changes:
tools/recordtotools/eventstestEnv.Stop()requiresEventuallywrapper for graceful shutdown1. (go/v4) Webhooks - Type-Safe API
Before (controller-runtime < v0.23.0)
After (controller-runtime >= v0.23.0)
Key Changes
NewWebhookManagedBy(mgr, &Type{})instead of using.For(&Type{})obj *Typeinstead ofobj runtime.ObjectLegacy Path Support: The
--legacyflag still works with the new API.Files Affected
internal/webhook/<version>/<kind>_webhook.go2. (deploy-image/v1-alpha) Events Recorder API
(Only valid for those who create APIs with the DeployImage Plugin)
controller-runtime v0.23 migrates event recording toward the newer
events.k8s.ioAPI. As part of this,mgr.GetEventRecorderFor(...)is deprecated and triggersSA1019in generated/sample projects.Updates included in this PR:
mgr.GetEventRecorderFor("...")withmgr.GetEventRecorder("...")in scaffoldedcmd/main.go(including projects scaffolded with the deploy-image plugin).Recorderfield type/imports accordingly (new events recorder API).Recorder.Event*calls to the new signature.events.k8s.ioAPI group when required.Before (controller-runtime < v0.23.0)
After (controller-runtime >= v0.23.0)
Key Changes
k8s.io/client-go/tools/record→k8s.io/client-go/tools/eventsrecord.EventRecorder→events.EventRecordermgr.GetEventRecorderFor()→mgr.GetEventRecorder()Event()→Eventf()with new signature (regarding, related objects)groups=core→groups=events.k8s.ioFiles Affected
cmd/main.gointernal/controller/<kind>_controller.go3. ENVTEST Teardown - AfterSuite with Eventually
controller-runtime v0.23.0 introduced timing changes in the test environment teardown process. Without using
Eventually,testEnv.Stop()can fail intermittently with errors related to graceful shutdown timing.Issue: Direct calls to
testEnv.Stop()may return errors if the cleanup isn't complete immediately, causing test suite failures during teardown.Solution: Wrap
testEnv.Stop()inEventuallywith a reasonable timeout to allow proper cleanup.Before (controller-runtime < v0.23.0)
After (controller-runtime >= v0.23.0)
Why This Change
The
Eventuallywrapper retries the stop operation for up to 1 minute (checking every second), ensuring the test environment has sufficient time to clean up resources gracefully. This prevents flaky test failures during suite teardown.Files Affected
internal/controller/suite_test.gointernal/webhook/<version>/<kind>_webhook_suite_test.go