Skip to content

Conversation

@RainbowMango
Copy link
Member

@RainbowMango RainbowMango commented Nov 14, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR updates controller-runtime to v0.22.4.

Which issue(s) this PR fixes:
Fixes #
Part of #6862

Special notes for your reviewer:
I'm surprised that no breaking change this time :)

Adopted changes:

Does this PR introduce a user-facing change?:

`Dependencies`: Updated `sigs.k8s.io/controller-runtime` from `v0.21.0` to `v0.22.4`.

Copilot AI review requested due to automatic review settings November 14, 2025 07:19
@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Nov 14, 2025
@karmada-bot karmada-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 14, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @RainbowMango, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request performs a significant upgrade of the controller-runtime library to version v0.22.4. The update introduces several key features, including a dedicated API for server-side apply, more flexible controller lifecycle management with warmup capabilities, and enhanced control over reconciliation timeouts. It also refines internal mechanisms like the priority queue and improves error resilience during manager shutdown, contributing to a more robust and feature-rich controller development experience.

Highlights

  • Dependency Update: The sigs.k8s.io/controller-runtime dependency has been bumped from v0.21.0 to v0.22.4, bringing in a range of new features and improvements.
  • Server-Side Apply (SSA) Support: A new Apply method has been introduced to the client.Client interface, providing native support for server-side apply operations. The fakeClient has also been enhanced to properly handle Apply and managed fields.
  • Controller Configuration Enhancements: New options EnableWarmup and ReconciliationTimeout have been added to controllers. EnableWarmup allows sources to start before leader election, improving failover, while ReconciliationTimeout sets a timeout for each reconcile call.
  • Priority Queue Improvements: The internal PriorityQueue now sorts items primarily by priority and then by readiness, ensuring higher priority items are processed first. Priority handling in event handlers has also been refined.
  • Manager and Leader Election Updates: The manager now includes a dedicated Warmup runnable group and improved error handling during shutdown. Leader election options have been extended to include LeaderLabels for lease objects.
  • Webhook Metrics and Logging: Conversion webhooks now include panic recovery and a new WebhookPanics metric for better observability. certwatcher has been updated to use logr.Logger.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copilot finished reviewing on behalf of RainbowMango November 14, 2025 07:20
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 updates sigs.k8s.io/controller-runtime from v0.21.0 to v0.22.4. This is a standard dependency update with vendored code from the upstream library.

Key changes include:

  • New Apply() client method support for Server-Side Apply
  • Warmup runnables feature for improved leader election failover
  • Enhanced fake client with managed fields support
  • Priority queue improvements and bug fixes

Reviewed Changes

Copilot reviewed 1 out of 42 changed files in this pull request and generated no comments.

File Description
go.mod, go.sum Updated controller-runtime dependency from v0.21.0 to v0.22.4
vendor/modules.txt Updated vendored module version reference
vendor/sigs.k8s.io/controller-runtime/** Vendored code updates from upstream controller-runtime library including new features, bug fixes, and API additions

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

Copy link

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

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 sigs.k8s.io/controller-runtime dependency from v0.21.0 to v0.22.4. This is a routine dependency update that brings in several improvements and new features from the upstream project. Notably, this version introduces client.Apply for server-side apply operations, which is now the recommended approach over client.Patch(..., client.Apply, ...). Other improvements include a new controller warmup feature and panic recovery in conversion webhooks. The changes are confined to go.mod, go.sum, and the vendor directory, which is expected for a dependency bump. The update appears to be handled correctly. This PR looks good to merge.

@RainbowMango RainbowMango force-pushed the pr_bump_controllerruntime_224 branch from 446c008 to e27887b Compare November 14, 2025 07:38
@RainbowMango
Copy link
Member Author

Echo failing tests here(see full log from here):

=== FAIL: pkg/controllers/execution TestExecutionController_Reconcile (unknown)
E1114 07:47:02.202518   21180 execution_controller.go:396] "Ignore event as failed to build event reference" err="missing mandatory kind" reason="WorkDispatching" kind="" object="karmada-es-cluster/work"
E1114 07:47:02.346380   21180 execution_controller.go:396] "Ignore event as failed to build event reference" err="missing mandatory kind" reason="WorkDispatching" kind="" object="karmada-es-cluster/work"
E1114 07:47:02.485382   21180 execution_controller.go:396] "Ignore event as failed to build event reference" err="missing mandatory kind" reason="WorkDispatching" kind="" object="karmada-es-cluster/work"
    execution_controller_test.go:201: 
        	Error Trace:	/home/runner/work/karmada/karmada/pkg/controllers/execution/execution_controller_test.go:201
        	Error:      	Not equal: 
        	            	expected: 1
        	            	actual  : 0
        	Test:       	TestExecutionController_Reconcile/work_dispatching_is_suspended,_adds_event_message
coverage: 17.8% of statements

The root cause is that since [email protected], the fake client will never populate the type meta(APIVersion and Kind) when getting the object, but that info is required to emit the event. See controller-runtime PR#3229

@RainbowMango RainbowMango force-pushed the pr_bump_controllerruntime_224 branch 2 times, most recently from f66c55d to 3e3707d Compare November 17, 2025 04:25
@RainbowMango
Copy link
Member Author

Another failing unit test(see full log from here):

=== Failed
=== FAIL: pkg/controllers/namespace TestController_Reconcile/Namespace_should_be_synced (1.21s)
    namespace_sync_controller_test.go:240: 
        	Error Trace:	/home/runner/work/karmada/karmada/pkg/controllers/namespace/namespace_sync_controller_test.go:240
        	Error:      	Received unexpected error:
        	            	works.work.karmada.io "test-namespace-57f54d795c" not found
        	Test:       	TestController_Reconcile/Namespace_should_be_synced
    --- FAIL: TestController_Reconcile/Namespace_should_be_synced (1.21s)

=== FAIL: pkg/controllers/namespace TestController_Reconcile (1.32s)

The test is expecting a work with the name test-namespace-57f54d795c to exist, but in the controller, the work name is generated without the typeMeta at:

workName := names.GenerateWorkName(namespaceObj.GetKind(), namespaceObj.GetName(), namespaceObj.GetNamespace())
. Same root cause as above.

@RainbowMango RainbowMango force-pushed the pr_bump_controllerruntime_224 branch from 3e3707d to 4d45e28 Compare November 17, 2025 06:56
@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.45%. Comparing base (27ca690) to head (d89c544).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6929      +/-   ##
==========================================
+ Coverage   46.43%   46.45%   +0.01%     
==========================================
  Files         698      698              
  Lines       47788    47792       +4     
==========================================
+ Hits        22189    22200      +11     
+ Misses      23929    23925       -4     
+ Partials     1670     1667       -3     
Flag Coverage Δ
unittests 46.45% <100.00%> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@RainbowMango
Copy link
Member Author

/gemini review

@RainbowMango RainbowMango added this to the v1.16 milestone Nov 17, 2025
Copy link

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

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 successfully updates controller-runtime from v0.21.0 to v0.22.4. The changes correctly address the breaking changes introduced in the new version, specifically by adding workarounds for the fake client's behavior regarding TypeMeta and by updating test mocks to include the new Apply method. The code modifications are well-commented and justified. The pull request is in good shape and ready for merging.

@RainbowMango
Copy link
Member Author

/retest

Creating namespace "karmada-tdf40wx8c7"...
>>> kubectl --request-timeout=30s create namespace karmada-tdf40wx8c7
namespace/karmada-tdf40wx8c7 created
>>> helm install karmada-tdf40wx8c7 charts/karmada --namespace karmada-tdf40wx8c7 --wait --timeout 800s --set components={search,metricsAdapter,descheduler},apiServer.hostNetwork=true

@RainbowMango
Copy link
Member Author

/retest

@RainbowMango RainbowMango force-pushed the pr_bump_controllerruntime_224 branch from 4d45e28 to d89c544 Compare November 19, 2025 08:06
@RainbowMango RainbowMango added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Nov 19, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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

@karmada-bot karmada-bot merged commit 2885a4f into karmada-io:master Nov 19, 2025
24 checks passed
@RainbowMango RainbowMango deleted the pr_bump_controllerruntime_224 branch November 19, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants