Skip to content

Conversation

@rohan-019
Copy link
Contributor

Description:
Stop enqueueing final DeleteEvents for Work to avoid redundant reconciliations (deletion is handled via the controller’s finalizer). Add a new predicate buildWorkEventPredicate() that:

  • Triggers on generation changes.
  • Triggers when DeletionTimestamp transitions nil → non-nil (so finalizer logic runs).
  • Ignores final DeleteEvents.

Notes:

  • Replaced the generic GenerationChangedPredicate with this explicit predicate.
  • If a custom WorkPredicateFunc is provided, ensure it doesn’t block the nil→non-nil deletion transition

Linked Issue:
part of #6780

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 17, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @rohan-019, 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 significantly refines how Work objects are reconciled within the controller by introducing a specialized event predicate. This change aims to reduce unnecessary reconciliation cycles, particularly around object deletion, by focusing on critical state transitions like generation changes and the initial marking for deletion. Concurrently, a minor but important adjustment has been made to the scheduler's logic to ensure more precise calculation of available replicas when considering historical assignments.

Highlights

  • Custom Work Event Predicate: Implemented buildWorkEventPredicate() to replace the generic GenerationChangedPredicate, allowing for more granular control over Work object reconciliation events.
  • Efficient Deletion Handling: The new predicate ensures reconciliation is triggered only when a Work object's DeletionTimestamp transitions from nil to non-nil, and explicitly ignores final DeleteEvents, preventing redundant processing.
  • Scheduler Replica Assignment Correction: Updated the scheduler's generateClustersInfo function to only factor in historical replica assignments for clusters that still possess available replicas, improving accuracy in resource allocation.
  • Comprehensive Unit Tests: Added a dedicated test file (execution_controller_predicate_test.go) with extensive unit tests for the new buildWorkEventPredicate to ensure its correctness and robustness across various scenarios.
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.

@rohan-019 rohan-019 force-pushed the reduce-unnecessary-watch-events-in-execution-status-controller branch from 8a557bd to 353d72a Compare October 17, 2025 15:55
@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 mszacillo for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

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 aims to reduce unnecessary reconciliations for Work resources by introducing a more specific event predicate. The new buildWorkEventPredicate correctly triggers on generation changes and initial deletion timestamping, while ignoring final delete events, which is a good optimization. The addition of unit tests for this new predicate is also a great practice.

My main feedback is a critical correction in execution_controller.go where the custom and default predicates are combined. The current implementation uses an AND logic, which could allow a custom predicate to block the essential deletion logic. I've suggested using predicate.Or to ensure the controller's finalizer logic is always triggered as intended. I also noticed a small, unrelated but correct fix in the scheduler's spread constraint logic.

@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2025

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

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.64%. Comparing base (70411ab) to head (5782ed9).
⚠️ Report is 57 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controllers/execution/execution_controller.go 0.00% 5 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6849      +/-   ##
==========================================
- Coverage   45.74%   45.64%   -0.11%     
==========================================
  Files         689      692       +3     
  Lines       57161    57706     +545     
==========================================
+ Hits        26149    26339     +190     
- Misses      29383    29722     +339     
- Partials     1629     1645      +16     
Flag Coverage Δ
unittests 45.64% <0.00%> (-0.11%) ⬇️

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.

@rohan-019
Copy link
Contributor Author

Hi @XiShanYongYe-Chang, I hope you are doing well
Please take a look at this!!

@rohan-019 rohan-019 changed the title Reduce unnecessary Work delete events — ignore final DeleteEvent, allow deletion-timestamp update Reduce unnecessary watch events in execution-status-controller Oct 17, 2025
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.

Thanks~

@karmada-bot karmada-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 20, 2025
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.

Thanks~

@karmada-bot karmada-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 21, 2025
@XiShanYongYe-Chang
Copy link
Member

XiShanYongYe-Chang commented Oct 21, 2025

Thanks @rohan-019 LGTM
Can you help squash the commits into one?

@rohan-019 rohan-019 force-pushed the reduce-unnecessary-watch-events-in-execution-status-controller branch from 8a32131 to 5782ed9 Compare October 21, 2025 12:10
@XiShanYongYe-Chang
Copy link
Member

Thanks @rohan-019 I'm sorry for the delay in response.
/lgtm
/cc @zach593 @RainbowMango

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. 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.

4 participants