-
Notifications
You must be signed in to change notification settings - Fork 859
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: refactor Karmada resource labels #3899
Conversation
Hi @jwcesign Just a reminder, this PR has conflicts, and it'd better to solve the conflicts first. |
has any progress? |
Hi @wu0407, I will complete it by the end of this week. Once it's done, I'll notify you for your review. |
01a32cb
to
083e59d
Compare
@jwcesign Could you please summarize the whole solution and point out what should be included in this PR(or v1.7)? |
aa9b1e2
to
56057ca
Compare
pkg/detector/detector.go
Outdated
objectCopy := object.DeepCopy() | ||
objectCopy.SetLabels(objLabels) | ||
objectCopy.SetAnnotations(objectAnnotations) | ||
util.MergeAnnotation(objectCopy, policyv1alpha1.PropagationPolicyNamespaceAnnotation, policy.Namespace) |
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.
could you extend util.MergeAnnotation
and util.MergeLabel
? they are not efficient, every annotation and label need to get object's and set. they should looks like this:
// MergeAnnotations adds annotations for the given object, keep the value unchanged if key exist.
func MergeAnnotations(obj *unstructured.Unstructured, annos map[string]string) {
objectAnnotation := obj.GetAnnotations()
if objectAnnotation == nil {
objectAnnotation = make(map[string]string, len(annos))
}
for annotationKey, annotationValue := range annos {
if _, exist := objectAnnotation[annotationKey]; !exist {
objectAnnotation[annotationKey] = annotationValue
}
}
obj.SetAnnotations(objectAnnotation)
}
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 we can do it in another 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.
thanks for your hard work 😊. this is a huge review effort, maybe we need more reviews.
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.
Still on reviewing.
pkg/util/helper/work.go
Outdated
workList, err := GetWorksByLabelsSet(c, ls) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
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.
Feel free to remove this part of the logic in the method, as using uid should ensure global uniqueness now.
Ask @chaunceyjiang to help make sure again.
96668e6
to
02e5122
Compare
02e5122
to
c8bb39b
Compare
Before starting the review, I have a question to ask: If Karmada has been restored and the UUID has changed, can Karmada still work properly? |
I will check it, in my opinion, I think the uid label should be updated(We can get the information from annotation and update it correctly, once it has changed) |
Good question! |
Yes, if we delete the work object through uuid, will the work object never be deleted when uuid changes? @jwcesign @RainbowMango |
Hi, @chaunceyjiang So, this means, velero only should back up the top-level resources, not back up the derived resources(like work, rb). If you back up the derived resources, like work, the old work will never be deleted(The label selector can't find the work now). What do you think? |
Signed-off-by: jwcesign <jwcesign@gmail.com>
0e72bac
to
737c9af
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 |
/close Track in the issue |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Please referring to #4000
Which issue(s) this PR fixes:
Fixes #4000
Special notes for your reviewer:
In PR:#4007, we add the owner information into the annotation.
This PR just use the annotation and the uid label for the handling logic.
Does this PR introduce a user-facing change?: