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

implementation of Policy LazyReconcile feature #4570

Closed
wants to merge 1 commit into from

Conversation

chaosi-zju
Copy link
Member

@chaosi-zju chaosi-zju commented Jan 21, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Implementation of Policy LazyReconcile feature.

When this feature is enabled, the resource will not immediately respond to policy modifications if it has already been distributed according to the previous policy. Instead, it will only respond to the policy changes during the next update of the resource.

More info refer to #4563

Which issue(s) this PR fixes:

Fixes part of #4563

Special notes for your reviewer:

This PR depends on the #4564, it is recommended to wait until the #4564 is merged and then rebase this PR before reviewing it.

Does this PR introduce a user-facing change?:

Introduced a Lazy Reconcile feature to PropagationPolicy/ClusterPropagationPolicy

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 21, 2024
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign garrybest after the PR has been reviewed.
You can assign the PR to them by writing /assign @garrybest in a comment when ready.

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

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 21, 2024
Comment on lines +1361 to +1396
func (d *ResourceDetector) addRelatedTemplateToProcessorQueue(policy *policyv1alpha1.ClusterPropagationPolicy) error {
resourceBindings, err := d.listCPPDerivedRB(policy.Name)
if err != nil {
return fmt.Errorf("failed to list CPP(%s) derived RB: %+v", policy.Name, err)
}
clusterResourceBindings, err := d.listCPPDerivedCRB(policy.Name)
if err != nil {
return fmt.Errorf("failed to list CPP(%s) derived CRB: %+v", policy.Name, err)
}
for _, rb := range resourceBindings.Items {
resourceKey, err := helper.ConstructClusterWideKey(rb.Spec.Resource)
if err != nil {
return fmt.Errorf("failed to get resource ClusterWideKey from RB(%s): %+v", rb.Name, err)
}
d.Processor.Add(resourceKey)
}
for _, crb := range clusterResourceBindings.Items {
resourceKey, err := helper.ConstructClusterWideKey(crb.Spec.Resource)
if err != nil {
return fmt.Errorf("failed to get resource ClusterWideKey from CRB(%s): %+v", crb.Name, err)
}
d.Processor.Add(resourceKey)
}
return nil
}

Copy link
Member Author

@chaosi-zju chaosi-zju Jan 21, 2024

Choose a reason for hiding this comment

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

Explanation: the reason for extracting this function is that the complexity of the code in the original function exceeded limits, causing ci-lint to crash.

@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2024

Codecov Report

Attention: 67 lines in your changes are missing coverage. Please review.

Comparison is base (f054313) 51.89% compared to head (f231722) 51.81%.

Files Patch % Lines
pkg/detector/detector.go 0.00% 47 Missing ⚠️
pkg/util/eventfilter/eventfilter.go 0.00% 19 Missing and 1 partial ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4570      +/-   ##
==========================================
- Coverage   51.89%   51.81%   -0.09%     
==========================================
  Files         246      246              
  Lines       24328    24370      +42     
==========================================
+ Hits        12626    12628       +2     
- Misses      11016    11055      +39     
- Partials      686      687       +1     
Flag Coverage Δ
unittests 51.81% <0.00%> (-0.09%) ⬇️

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.

Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
}

// check whether there are matched RT in waiting list, is so, add it to processor
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// check whether there are matched RT in waiting list, is so, add it to processor
// check whether there are matched RT in waiting list, if so, add it to processor

// If Policy LazyReconcile feature enabled, ignore the label/annotation modifications by karmada's own components.
if features.FeatureGate.Enabled(features.PolicyLazyReconcile) {
// Remove the labels or annotations modified by karmada's own components.
for k := range oldBackup.GetLabels() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a reference, can we extract the deletion of labels and annotations controlled by Karmada into a independent function? This will ensure consistency in the operations of newBackup and oldBackup.

@chaosi-zju
Copy link
Member Author

/close

this implementation is deprecated, replaced by #4577.

@karmada-bot
Copy link
Collaborator

@chaosi-zju: Closed this PR.

In response to this:

/close

this implementation is deprecated, replaced by #4577.

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. 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.

4 participants