-
Notifications
You must be signed in to change notification settings - Fork 918
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.35% 48.09% -0.26%
==========================================
Files 666 669 +3
Lines 54831 55186 +355
==========================================
+ Hits 26513 26543 +30
- Misses 26599 26916 +317
- Partials 1719 1727 +8
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!
[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 |
fix: get false when suspendDispatching is nil fix: ignore work events when suspendDispatching is true feat: rename workIndex and mv GetWorkSuspendDispatching to helper feat: modify the style of Deprecated Signed-off-by: vie-serendipity <[email protected]>
59e2e2b
to
85f3dca
Compare
) | ||
|
||
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
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) {
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?: