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(detector): Fix the invalid behavior in the detector to determine whether the binding object needs to be updated. #6157

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

CharlesQQ
Copy link
Member

@CharlesQQ CharlesQQ commented Feb 24, 2025

What type of PR is this?
/kind feature

What this PR does / why we need it:

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

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


`karmada-controller-manager`: Fixed the issue where the `detector` unnecessary updates for RB issue.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 24, 2025
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 24, 2025
@XiShanYongYe-Chang
Copy link
Member

Nice catching @CharlesQQ

We add a new finalizer karmada.io/binding-dependencies-distributor to the binding object corresponding to the resource to be followed in the dependencies distributor in #4983, this results in inconsistency of finalizers when the binding object is updated in the detector.

Based on this change, when the controller restarts, does the check on the binding object deepequal take effect? Do you have the test result?

@CharlesQQ
Copy link
Member Author

CharlesQQ commented Feb 24, 2025

does the check on the binding object deepequal take effect? Do you have the test result?

After testing, the detector will not update rb that has not changed during the restart, and the results are in line with expectations.

image
image

@CharlesQQ CharlesQQ changed the title fix(detector): fix new binding object fix(detector): Fix the invalid behavior in the detector to determine whether the binding object needs to be updated. Feb 24, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 24, 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 48.11%. Comparing base (006cf70) to head (5d2fe25).
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    #6157      +/-   ##
==========================================
+ Coverage   48.07%   48.11%   +0.03%     
==========================================
  Files         668      668              
  Lines       55327    55344      +17     
==========================================
+ Hits        26597    26626      +29     
+ Misses      26992    26982      -10     
+ Partials     1738     1736       -2     
Flag Coverage Δ
unittests 48.11% <100.00%> (+0.03%) ⬆️

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.

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~
Do we need a release note?
/lgtm

/cc @RainbowMango

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2025
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

Comment on lines 131 to 132
if existFinalizers == nil {
return existFinalizers
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why it needs a return here, but I don't think it should be.
Consider one situation where len(existFinalizer) != 0 and len(newFinalizers) > 0.

if equality.Semantic.DeepEqual(existFinalizerSets, newFinalizerSets) {
return existFinalizers
}
return newFinalizerSets.UnsortedList()
Copy link
Member

Choose a reason for hiding this comment

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

Here should return a sorted list, right?

Copy link
Member

Choose a reason for hiding this comment

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

The order should be

items in exist --> items in new(but not in exist)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll fix it, pls review again @RainbowMango

@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2025
@XiShanYongYe-Chang
Copy link
Member

I update the labels.
/kind bug
/remove-kind feature

@karmada-bot karmada-bot added kind/bug Categorizes issue or PR as related to a bug. and removed kind/feature Categorizes issue or PR as related to a new feature. labels Feb 25, 2025
@CharlesQQ
Copy link
Member Author

/retest

@XiShanYongYe-Chang
Copy link
Member

@CharlesQQ can you help add a release note? We need it when we cherry-pick it.

@@ -560,6 +560,7 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured,
// Just update necessary fields, especially avoid modifying Spec.Clusters which is scheduling result, if already exists.
bindingCopy.Annotations = util.DedupeAndMergeAnnotations(bindingCopy.Annotations, binding.Annotations)
bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, binding.Labels)
bindingCopy.Finalizers = util.DedupeAndMergeFinalizers(bindingCopy.Finalizers, binding.Finalizers)
Copy link
Member

Choose a reason for hiding this comment

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

Is this the only place that needs modification?
My understanding is that after the detector creates ResourceBindng/ClusterResourceBinding, downstream controllers could potentially append finalizers. Therefore, I think all places where updating RB/CRB should be fixed.

@XiShanYongYe-Chang What's your opinion?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think all places where updating RB/CRB should be fixed

Oh

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

For the CRB, it is OK not to modify the CRB, because the dependency distribution does not add the related finalizer to the CRB resource.

Of course, the modification is better, which can avoid the same problem in the future.

@RainbowMango
Copy link
Member

/remove-kind feature
/kind bug

@karmada-bot
Copy link
Collaborator

@RainbowMango: Those labels are not set on the issue: kind/feature

In response to this:

/remove-kind feature
/kind bug

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@CharlesQQ
Copy link
Member Author

can you help add a release note? We need it when we cherry-pick it.

Which release should I cherry-pick to? @XiShanYongYe-Chang

@XiShanYongYe-Chang
Copy link
Member

Which release should I cherry-pick to? @XiShanYongYe-Chang

We introduced this problem in v1.10, and we need to maintain the last three versions, so we need to cherry-pick it to the release-1.12, release-1.11 and release-1.10 branch.

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 Feb 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 Feb 26, 2025
@karmada-bot karmada-bot merged commit 7b29afb into karmada-io:master Feb 26, 2025
21 checks passed
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix the invalid behavior in the detector to determine whether the binding object needs to be updated.
5 participants