-
Notifications
You must be signed in to change notification settings - Fork 924
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: replace instruction annotation with work suspendDispatching field #6043
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #6043 +/- ##
=======================================
Coverage 48.07% 48.07%
=======================================
Files 668 669 +1
Lines 55327 55348 +21
=======================================
+ Hits 26597 26608 +11
- Misses 26992 27003 +11
+ Partials 1738 1737 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
982414c
to
2f2ae0a
Compare
/retest |
Thanks~ |
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.
Thanks a lot~
pkg/util/work.go
Outdated
) | ||
|
||
// GetWorkSuspendDispatching will get suspendDispatching field from work spec | ||
func GetWorkSuspendDispatching(spec *workv1alpha1.WorkSpec) []string { |
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.
How about moving this function to the pkg/util/helper/work.go
file?
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.
ok
pkg/controllers/mcs/common.go
Outdated
) | ||
|
||
const ( | ||
workKeyIndex = "workSpec.suspendDispatching" |
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.
How about renaming this to workSuspendDispatchdingIndex
?
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.
ok
pkg/util/constants.go
Outdated
@@ -46,7 +46,7 @@ const ( | |||
// | |||
// Note: This instruction is intended to set on Work objects to indicate the Work should be ignored by | |||
// execution controller. The instruction maybe deprecated once we extend the Work API and no other scenario want this. | |||
PropagationInstruction = "propagation.karmada.io/instruction" | |||
PropagationInstruction = "propagation.karmada.io/instruction" // deprecated |
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.
There are still some places in the warehouse that use the variable. Should we replace all the places that use the variable?
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.
Now I think we should retain the handling of this label. I just replaced the usage of PropagationInstruction
with suspendDispatching
in the repository when creating new resources, ensuring NO new resources with the PropagationInstruction
label are created. And we can remove it entirely later.
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.
Thanks for the explanation, I think we can clean them up in the next version(v1.14).
By the way, can we mark the PropagationInstruction
and the related value to be deprecated like this:
// Deprecated
PropagationInstruction = "propagation.karmada.io/instruction"
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.
done
util.ServiceNamespaceLabel: endpointSlice.GetNamespace(), | ||
util.ServiceNameLabel: endpointSlice.GetLabels()[discoveryv1.LabelServiceName], | ||
// indicate the Work should be not propagated since it's collected resource. | ||
util.PropagationInstruction: util.PropagationInstructionSuppressed, |
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.
Can we delete this variable in the next version to consider compatibility?
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.
I think removing this tag won't cause compatibility issues, because I've retained the handling logic for PropagationInstruction
, which will still work as intended.
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.
Yes, you are right!
59e2e2b
to
85f3dca
Compare
pkg/controllers/mcs/common.go
Outdated
) | ||
|
||
const ( | ||
workSuspendDispatchdingIndex = "workSpec.suspendDispatching" |
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.
Sorry I made a mistake in my previous comment, a typo Dispatchding -> Dispatching
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.
ok, my mistake, I didn't double check.
if IsWorkSuspendDispatching(obj) { | ||
klog.V(5).Infof("Ignored Work(%s/%s) %s event as dispatching is suspended.", obj.Namespace, obj.Name, eventType) | ||
return false | ||
} |
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.
Should such a judgment be added to other places where judgment util.GetLabelValue(obj.Labels, util.PropagationInstruction) == util.PropagationInstructionSuppressed
is used, because for users who directly use this version (v1.13), the work in the environment will not have the propagation.karmada.io/instruction
label.
For example:
--- a/pkg/controllers/ctrlutil/work.go
+++ b/pkg/controllers/ctrlutil/work.go
@@ -36,7 +36,8 @@ import (
// CreateOrUpdateWork creates a Work object if not exist, or updates if it already exists.
func CreateOrUpdateWork(ctx context.Context, client client.Client, workMeta metav1.ObjectMeta, resource *unstructured.Unstructured, options ...WorkOption) error {
- if workMeta.Labels[util.PropagationInstruction] != util.PropagationInstructionSuppressed {
+ if workMeta.Labels[util.PropagationInstruction] != util.PropagationInstructionSuppressed ||
+ IsWorkSuspendDispatching(obj) {
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.
I think the handling here is not necessary, we can directly remove it if we use suspendDispatching
. For some other places, we cannot use suspendDispatching
filter because the suspendDispatching condition for work needs to be updated in reconcile.
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.
I think the handling here is not necessary, we can directly remove it if we use suspendDispatching.
For a new work formed by collecting Endpointslices, this condition judgment is always valid, which is equivalent to invalid judgment.
For some other places, we cannot use suspendDispatching filter because the suspendDispatching condition for work needs to be updated in reconcile.
I'm sorry, I don't quite understand this point. Could you explain it a little bit?
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.
I mean, when using PropagationInstruction
for the execution controller's predicate, the suspendDispatching field cannot be used as a filtering condition because the execution controller needs to update the Dispatching condition.
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.
For a new work formed by collecting Endpointslices, this condition judgment is always valid, which is equivalent to invalid judgment.
So I think we can remove this judgment directly, according to my understanding adding labels and annotations to the work's manifest should be fine.
I'm worried that if we add IsWorkSuspendDispatching(obj)
in the jugement here, user-created suspended works might lose these label and annotation information. If we add IsWorkSuspendDispatching(obj)
here, we might add some handle in the mutating webhook.
karmada/pkg/webhook/work/mutating.go
Lines 74 to 77 in 4982157
// Skip label/annotate the workload of Work that is not intended to be propagated. | |
if work.Labels[util.PropagationInstruction] != util.PropagationInstructionSuppressed { | |
setLabelsAndAnnotationsForWorkload(workloadObj, work) | |
} |
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.
Sorry about progress, I'm busy lately, I'll probably test it next week, are there any releases planned lately that require this pr?
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.
Version 1.13 will be released at the end of February. I'm not sure if we can catch up with it. Let's follow your schedule.
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.
I tested and it works fine. I followed the following steps to test:
- Use local-up-karmada script to make a test enviroment.
- Build my karmada controller manager image and use it.
- Follow https://karmada.io/docs/userguide/service/multi-cluster-service to test multi cluster discovery.
- Endpointslice is propagted correctly.
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.
Thanks for your test!
I think we can move on. The current pr and master branch conflict, can you help solve it?
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.
sure
85f3dca
to
75d0f1d
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
75d0f1d
to
50dafe2
Compare
feat: rename workIndex and mv GetWorkSuspendDispatching to helper feat: modify the style of Deprecated Signed-off-by: vie-serendipity <[email protected]> feat: label and annotate workloads even though work is suspended Signed-off-by: vie-serendipity <[email protected]> test: fix ut for CreateOrUpdateWork Signed-off-by: vie-serendipity <[email protected]>
50dafe2
to
eee26ca
Compare
What type of PR is this?
/kind deprecation
What this PR does / why we need it:
Replace
propagation.karmada.io/instruction
withsuspendDispatching
field. Annotation was just a temporary solution. With the native support of the work API, we should deprecate the use of annotations and utilize the work field instead.Which issue(s) this PR fixes:
Fixes #5386
Special notes for your reviewer:
Does this PR introduce a user-facing change?: