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

feat: When a resource is created for the first time, it should also be considred as a modification. #4583

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chaunceyjiang
Copy link
Member

@chaunceyjiang chaunceyjiang commented Jan 26, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:

If the first creation is not considered as a modification, then resources like GatewayClass, IPPool can never be propagated to member clusters. Because once they are created, they will never be modified.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: When a resource is created for the first time, it should also be considred as a modification.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 26, 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 26, 2024
@chaunceyjiang
Copy link
Member Author

/cc @RainbowMango @chaosi-zju PTAL.

@RainbowMango
Copy link
Member

If the initial creation is not considered as a modification

What do you mean the initial creation?

@chaunceyjiang
Copy link
Member Author

What do you mean the initial creation?

First time creating to k8s

pkg/detector/detector.go Show resolved Hide resolved
pkg/detector/detector.go Outdated Show resolved Hide resolved
…e considered as a modification.

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
@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 Jan 26, 2024
@@ -69,7 +69,7 @@ func (d *ResourceDetector) propagateResource(object *unstructured.Unstructured,
}
d.RemoveWaiting(objectKey)
metrics.ObserveFindMatchedPolicyLatency(start)
return d.ApplyPolicy(object, objectKey, resourceChangeByKarmada, propagationPolicy)
return d.ApplyPolicy(object, objectKey, false, propagationPolicy)
Copy link
Member Author

Choose a reason for hiding this comment

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

/cc @RainbowMango @chaosi-zju

My core idea is: Whether PP is Lazy or immediate, it should be immediate when the resources have not yet been bound by PP.

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 believe Lazy should only take effect after the PP is bound with resources.

Copy link
Member

Choose a reason for hiding this comment

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

does this PR want to resolve the problem #4577 (comment) you memtioned here?

Copy link
Member Author

Choose a reason for hiding this comment

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

does this PR want to resolve the problem #4577 (comment) you memtioned here?

No, these are two different issues.

  1. The issue in Introduced a lazy activation preference to PropagationPolicy/ClusterPropagationPolicy #4577 (comment) is that using a single PP to select two resources with different effects.

  2. This PR wants to introduce "Lazy should only take effect after the PP is bound with resources."

Copy link
Member

@chaosi-zju chaosi-zju Jan 26, 2024

Choose a reason for hiding this comment

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

Assuming that a resource has been distributed according to PolicyA.

Then PolicyA deleted, or changed resourceSelector and no longer match to the resource.

The detecor will remove the policy label in resource immediately.

This will also triggle resoure updated.

In this case, resouce will look for a new policy (PolicyB), if PolicyB is Lazy, the binding should be unchanged.

The related pods of the reosource running just fine, we shouldn't break it just because policy change.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, resouce will look for a new policy, if this policy is Lazy, the binding should be unchanged.

Good question, your question introduces a new thought, whether the binding of PP and resources is Lazy or Immediate.

Copy link
Member

Choose a reason for hiding this comment

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

Lazy should only take effect after the PP is bound with resources.

This principle is what I want too, and I couldn't agree more.

However, there is an ambiguity in our understanding of buond. I understand bound to mean that a resource is bound when it is labelled with a policy, whereas you think that a resource is bound when it is refreshed with a binding following a policy.

Copy link
Member

Choose a reason for hiding this comment

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

your question introduces a new thought, whether the binding of PP and resources is Lazy or Immediate.

So the core of my proposal is The impact of Policy changes on the bondage relationship between resources and Policy is always immediate, but whether the resource needs to synchronize the latest placement to the binding immediately is determined by this field.

Pay attention to the bondage relationship between resources and Policy is always immediate, when a resource is labelled with a policy, just finish label, it finished the bound.

after bound, there's only ever one definitive policy for this resource, if this policy is lazy, don't change the resource's binding.

This would be the clearest behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pay attention to the bondage relationship between resources and Policy is always immediate, when a resource is labelled with a policy, just finish label, it finished the bound.

I got you.
However, most resources, once created, will not be changed.

As i said:

then resources like GatewayClass, IPPool can never be propagated to member clusters. Because once they are created, they will never be modified.

@codecov-commenter
Copy link

Codecov Report

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

Comparison is base (ae5b3fe) 51.69% compared to head (0028f79) 51.71%.

Files Patch % Lines
pkg/detector/detector.go 0.00% 4 Missing ⚠️
pkg/detector/policy.go 0.00% 2 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4583      +/-   ##
==========================================
+ Coverage   51.69%   51.71%   +0.01%     
==========================================
  Files         247      247              
  Lines       24418    24418              
==========================================
+ Hits        12624    12627       +3     
+ Misses      11106    11104       -2     
+ Partials      688      687       -1     
Flag Coverage Δ
unittests 51.71% <0.00%> (+0.01%) ⬆️

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.

@chaunceyjiang
Copy link
Member Author

https://docs.google.com/document/d/1y6YLVC-v7cmVAdbjedoyR5WL0-q45DBRXTvz5_I7bkA/edit#heading=h.uh2zpyfy7tw4

After discussions in the community, it is currently considered appropriate to introduce a new type of Lazy.

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/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.

5 participants