-
Notifications
You must be signed in to change notification settings - Fork 890
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
add implicit priority for OP and COP #2609
Conversation
/assign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this PR can really work but also a little complicated. I suppose we actually don't need to sort this slice, the only thing we need is to find the most appropriate one, right?
IMO, sort function could be transformed to pick up a most appropriate one. This function receives a []util.GeneralPolicy
as an input and returns a int
index as output. This index indicates the most appropriate one, or -1 if mismatches.
How do you think?
+1 By the way, I think combining |
🤔 |
+1 |
Seems like it's not appropriate to combine OP and PP. IIRC, all matched OP should be applied while only one pp will be selected. It's totally different. |
yes, But the |
Got it. However, I thought we don't actually need a sort function indeed, against PP we pick up the most appropriate one, against OP we pick up all the appropriate ones. The complexity could be optimized from O(NlogN) to O(N). |
🤔 There are two OP Apply The final result is different apiVersion: policy.karmada.io/v1alpha1
kind: OverridePolicy
metadata:
name: sample-1
spec:
resourceSelectors:
- apiVersion: webapp.my.domain/v1
kind: Guestbook
overrideRules:
- targetCluster:
clusterNames:
- member1
overriders:
plaintext:
- path: /spec/size
operator: replace
value: 4 apiVersion: policy.karmada.io/v1alpha1
kind: OverridePolicy
metadata:
name: sample-2
spec:
resourceSelectors:
- apiVersion: webapp.my.domain/v1
kind: Guestbook
overrideRules:
- targetCluster:
clusterNames:
- member1
overriders:
plaintext:
- path: /spec/size
operator: add
value: 4 |
Indeed. This is a sort case. |
dc992f3
to
7bc59ba
Compare
7bc59ba
to
c7e27a0
Compare
Codecov Report
@@ Coverage Diff @@
## master #2609 +/- ##
==========================================
+ Coverage 37.61% 37.71% +0.09%
==========================================
Files 189 200 +11
Lines 17657 18445 +788
==========================================
+ Hits 6642 6956 +314
- Misses 10612 11082 +470
- Partials 403 407 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
c7e27a0
to
20321ed
Compare
@Garrybest What do you think? |
Generally LGTM, except this nit. #2609 (comment) |
20321ed
to
f41df14
Compare
/lgtm |
I'm asking myself, what benefits can we get from it? What's the possible use case? Can you remind me? |
I think it's reasonable, like applying the user's OP first( |
That's a reasonable case. Thanks. |
I'll take a look it tomorrow and try my best to add this to release 1.4. |
f41df14
to
1727742
Compare
1727742
to
ace6f3c
Compare
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
ace6f3c
to
200a587
Compare
Generally, it looks good to me, cc @RainbowMango to take a look |
@RainbowMango @XiShanYongYe-Chang What do you think? |
Generally looks good to me.
Please help to confirm. |
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
Thanks for the quick response.
[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 |
/lgtm |
Signed-off-by: chaunceyjiang chaunceyjiang@gmail.com
What type of PR is this?
/kind feature
What this PR does / why we need it:
add implicit priority for OP and COP
Which issue(s) this PR fixes:
like #2267
Special notes for your reviewer:
Does this PR introduce a user-facing change?: