Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the issue where the binding gracefulEvictionTask can never be clear #6227

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

XiShanYongYe-Chang
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang commented Mar 24, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

When the binding object is scheduled but there is no result, the SchedulerObservedGeneration in the binding object status will not be set to the generation value, which results in graceful-eviction-controller will not be able to handle gracefulEvictionTask and will always remain.

Which issue(s) this PR fixes:
Fixes #3747

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: Fixed the issue that the gracefulEvictionTask of ResourceBinding can not be cleared in case of schedule fails.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 24, 2025
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 24, 2025
@XiShanYongYe-Chang XiShanYongYe-Chang changed the title Move generation judgment logic to give the chance to clear the gracefulEvictionTask when generation judgment always false fix the issue where the binding gracefulEvictionTask can never be clear Mar 24, 2025
…gracefulEvictionTask clearance, move the generation judgment logic to the reconcile

Signed-off-by: changzhen <changzhen5@huawei.com>
@codecov-commenter
Copy link

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

Codecov Report

Attention: Patch coverage is 73.07692% with 7 lines in your changes missing coverage. Please review.

Project coverage is 47.89%. Comparing base (0235dc6) to head (cbfc085).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controllers/gracefuleviction/evictiontask.go 70.00% 2 Missing and 1 partial ⚠️
...acefuleviction/crb_graceful_eviction_controller.go 75.00% 2 Missing ⚠️
...racefuleviction/rb_graceful_eviction_controller.go 75.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6227      +/-   ##
==========================================
- Coverage   47.90%   47.89%   -0.02%     
==========================================
  Files         676      676              
  Lines       55962    55962              
==========================================
- Hits        26809    26801       -8     
- Misses      27405    27410       +5     
- Partials     1748     1751       +3     
Flag Coverage Δ
unittests 47.89% <73.07%> (-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 Author

/cc @RainbowMango

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/assign

Copy link
Contributor

@Copilot 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 fixes the issue where a binding’s gracefulEvictionTask can never be cleared by updating how tasks are assessed and retried. Key changes include:

  • Changing the assessEvictionTasks call to accept a structured assessmentOption containing scheduling and observed status information.
  • Updating the predicate functions in both RB and CRB controllers to simplify task emptiness checks.
  • Modifying test cases and adding the Generation field to ensure proper scheduling status handling.

Reviewed Changes

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

Show a summary per file
File Description
pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go Updates assessEvictionTasks call and predicate logic for ResourceBinding
pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go Updates assessEvictionTasks call and predicate logic for ClusterResourceBinding
pkg/controllers/gracefuleviction/evictiontask.go Introduces a new "hasScheduled" field in assessmentOption and adjusts task assessment
pkg/controllers/gracefuleviction/evictiontask_test.go Adjusts test cases to align with the new task evaluation including hasScheduled flag
pkg/controllers/gracefuleviction/rb_graceful_eviction_controller_test.go Adds Generation to the binding to simulate correct scheduling behavior
pkg/controllers/gracefuleviction/crb_graceful_eviction_controller_test.go Adds Generation to the binding to simulate correct scheduling behavior
Comments suppressed due to low confidence (3)

pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go:114

  • Removing the check for SchedulerObservedGeneration may trigger unnecessary reconciliations. If this change is intentional, please add a comment to document the new behavior.
return len(newObj.Spec.GracefulEvictionTasks) != 0

pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go:114

  • Eliminating the check for SchedulerObservedGeneration might lead to processing update events even when scheduling hasn’t changed. Please verify if this change is intended and document accordingly.
return len(newObj.Spec.GracefulEvictionTasks) != 0

pkg/controllers/gracefuleviction/evictiontask.go:50

  • [nitpick] Consider using a temporary variable for the per-task timeout instead of modifying the opt.timeout field directly. This change could improve clarity by keeping the assessmentOption immutable within each loop iteration.
if task.GracePeriodSeconds != nil { opt.timeout = time.Duration(*task.GracePeriodSeconds) * time.Second }

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2025
@karmada-bot karmada-bot merged commit ba782c8 into karmada-io:master Mar 26, 2025
24 checks passed
@RainbowMango
Copy link
Member

Please help to cherry-pick this to release branches.

karmada-bot added a commit that referenced this pull request Mar 26, 2025
…k-of-#6227-upstream-release-1.11

Automated cherry pick of #6227: to prevent the generation judgment from always being false
karmada-bot added a commit that referenced this pull request Mar 26, 2025
…k-of-#6227-upstream-release-1.13

Automated cherry pick of #6227: to prevent the generation judgment from always being false
karmada-bot added a commit that referenced this pull request Mar 26, 2025
…k-of-#6227-upstream-release-1.12

Automated cherry pick of #6227: to prevent the generation judgment from always being false
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/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graceful eviction tasks in resource binding never cleaned
4 participants