Skip to content

Conversation

@yaten2302
Copy link

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

The cert-rotation-controller only need to watch the creation event of the cluster object, as the cluster object will be processed periodically, so there is no need to watch the update or deletion events of the cluster.

Which issue(s) this PR fixes:

Fixes #6780

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Dec 2, 2025
@karmada-bot
Copy link
Collaborator

Welcome @yaten2302! It looks like this is your first PR to karmada-io/karmada 🎉

@karmada-bot
Copy link
Collaborator

[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 xishanyongye-chang for approval. For more information see the 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

@gemini-code-assist
Copy link

Summary of Changes

Hello @yaten2302, 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 refines the event watching mechanism within the cert-rotation-controller by eliminating unnecessary processing of update and delete events for cluster objects. Since cluster objects are processed periodically, actively watching these events is redundant, and this change streamlines the controller's operation for improved efficiency.

Highlights

  • Event Watching Optimization: The cert-rotation-controller has been optimized to only watch for creation events of cluster objects, explicitly ignoring update and delete events, as periodic processing makes these watches redundant.
  • Predicate Function Update: The UpdateFunc and DeleteFunc within the NewClusterPredicateOnAgent function in pkg/util/helper/predicate.go have been modified to always return false, preventing the controller from reacting to these events.
  • Test Case Adjustment: Corresponding test cases in pkg/util/helper/predicate_test.go have been updated to reflect the new behavior, asserting that update and delete events are now correctly ignored by the predicate.
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.

@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 2, 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 correctly removes the handling of update and delete events in NewClusterPredicateOnAgent. By making UpdateFunc and DeleteFunc always return false, any controller using this predicate will no longer trigger unnecessary reconciliations for these events, which is a good optimization. The accompanying test changes in predicate_test.go accurately reflect this new behavior. The change is sound and well-implemented.

@XiShanYongYe-Chang
Copy link
Member

Hi @zhzhuang-zju can you help take a review?
/cc @zhzhuang-zju

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 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.60%. Comparing base (679674f) to head (97dc3da).
⚠️ Report is 4 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6989      +/-   ##
==========================================
- Coverage   46.62%   46.60%   -0.02%     
==========================================
  Files         699      699              
  Lines       48164    48156       -8     
==========================================
- Hits        22456    22445      -11     
- Misses      24013    24016       +3     
  Partials     1695     1695              
Flag Coverage Δ
unittests 46.60% <100.00%> (-0.02%) ⬇️

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.

@XiShanYongYe-Chang
Copy link
Member

Hi @yaten2302, there are some lint errors.

@karmada-bot karmada-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 2, 2025
@yaten2302
Copy link
Author

Hi @XiShanYongYe-Chang , the CI workflow which is failing, I've a doubt that, the failing test is - https://github.com/karmada-io/karmada/actions/runs/19868522315/job/56938370989?pr=6989. But, this comes under resource-status collection, right? Is this related to the cert-rotation controller.

I've fixed the linter errors though 👀 the workflow is passing for that.

@XiShanYongYe-Chang
Copy link
Member

/retest

@yaten2302
Copy link
Author

@XiShanYongYe-Chang , kindly approve one pending test :)

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Hi, @yaten2302
The current predicate is being used by two controllers, but the current modification logic does not apply to the cluster-status-controller. You may need to adjust the modification method to prevent the impact from spreading.

@yaten2302
Copy link
Author

@XiShanYongYe-Chang , ig you already have an open PR for this :)
#6832 in here, for the cluster-status-controller, the NewClusterPredicateOnAgent func is changed to NewClusterStatusControllerPredicateOnAgent.

Once your PR is merged, this will prevent the effect from spreading. Should I incorporate this behaviour in my PR?

@XiShanYongYe-Chang
Copy link
Member

You're right. Let's wait for my PR to be merged first, so you can rebase later.

If you are willing to continue contributing, you can follow up on this issue:
#6952

@yaten2302
Copy link
Author

You're right. Let's wait for my PR to be merged first, so you can rebase later.

Sure 👍

If you are willing to continue contributing, you can follow up on this issue:
#6952

Yes, I'm willing to contribute more to the project, I'll pick up one more good first issue and then I'll probably try to find some good ones, like major changes/refactor/bugs or anything required at that point.
BTW, is there is any medium for communication like slack channel or community calls? I've joined the karmada-dev channel in CNCF slack, but that's quite inactive ig? is that only the medium for communications and all?

@XiShanYongYe-Chang
Copy link
Member

BTW, is there is any medium for communication like slack channel or community calls? I've joined the karmada-dev channel in CNCF slack, but that's quite inactive ig? is that only the medium for communications and all?

Currently using the Karmada channel in CNCF Slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Umbrella] Reduce unnecessary resource watch events in the karmada controllers

4 participants