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

feature: Add the UID of the owner resource in labels and include the details in annotations. #4007

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

jwcesign
Copy link
Member

What type of PR is this?
/kind feature

What this PR does / why we need it:
As mentioned in #4000

Which issue(s) this PR fixes:
Part of #4000

Special notes for your reviewer:
none

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: Include the UID of the owner resource in labels and provide the details in annotations. If users are using related labels as label selectors, they should switch to using the UID as the label selector.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 26, 2023
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 26, 2023
@jwcesign
Copy link
Member Author

@karmada-bot
Copy link
Collaborator

@jwcesign: GitHub didn't allow me to request PR reviews from the following users: wu0407.

Note that only karmada-io members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @RainbowMango @wu0407 @whitewindmills

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jwcesign
Copy link
Member Author

jwcesign commented Aug 26, 2023

Note: In version v1.8.0, we will remove the old labels, resolving the issue of excessively long label values.

Testing report: https://docs.google.com/document/d/1FgHm5gdgSB9cuSj526i6P-1g9lUwIaaeXAt-bUjM834/edit?usp=sharing

@codecov-commenter
Copy link

codecov-commenter commented Aug 26, 2023

Codecov Report

Merging #4007 (2c48bd7) into master (fb4c16d) will increase coverage by 0.11%.
Report is 8 commits behind head on master.
The diff coverage is 14.51%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #4007      +/-   ##
==========================================
+ Coverage   54.48%   54.59%   +0.11%     
==========================================
  Files         232      232              
  Lines       22685    22894     +209     
==========================================
+ Hits        12359    12500     +141     
- Misses       9649     9715      +66     
- Partials      677      679       +2     
Flag Coverage Δ
unittests 54.59% <14.51%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
pkg/detector/detector.go 0.00% <0.00%> (ø)
pkg/detector/preemption.go 0.00% <0.00%> (ø)
pkg/util/annotation.go 84.12% <0.00%> (-12.24%) ⬇️
pkg/controllers/binding/common.go 47.72% <88.88%> (+2.16%) ⬆️
pkg/controllers/execution/execution_controller.go 59.35% <100.00%> (ø)

... and 7 files with indirect coverage changes

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/assign

@RainbowMango RainbowMango added this to the v1.7 milestone Aug 26, 2023
@RainbowMango
Copy link
Member

This test is failing:

--- FAIL: TestExecutionController_syncWork (0.59s)
    --- PASS: TestExecutionController_syncWork/failed_to_GetObjectFromCache,_wrong_InformerManager_in_ExecutionController (0.03s)
    --- PASS: TestExecutionController_syncWork/obj_not_found_in_informer,_wrong_dynamicClientSet_without_pod (0.13s)
    --- PASS: TestExecutionController_syncWork/workNamespace_is_zero (0.13s)
    --- PASS: TestExecutionController_syncWork/failed_to_exec_Client.Get,_set_wrong_cluster_name_in_work (0.13s)
    --- PASS: TestExecutionController_syncWork/cluster_is_not_ready (0.04s)
    --- FAIL: TestExecutionController_syncWork/normal_case (0.14s)
FAIL
	github.com/karmada-io/karmada/pkg/controllers/execution	coverage: 67.7% of statements
FAIL	github.com/karmada-io/karmada/pkg/controllers/execution	1.168s
?   	github.com/karmada-io/karmada/pkg/controllers/federatedhpa	[no test files]
?   	github.com/karmada-io/karmada/pkg/controllers/federatedhpa/config	[no test files]
?   	github.com/karmada-io/karmada/pkg/controllers/federatedhpa/monitor	[no test files]

Signed-off-by: jwcesign <jwcesign@gmail.com>
Copy link
Member

@whitewindmills whitewindmills left a comment

Choose a reason for hiding this comment

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

/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2023
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 28, 2023
@karmada-bot karmada-bot merged commit b852552 into karmada-io:master Aug 28, 2023
12 checks passed
@wu0407
Copy link
Contributor

wu0407 commented Aug 29, 2023

This PR does not fix the create resource binding failed by DependenciesDistributor, it only fixes the failed to create resource for the member cluster.

@RainbowMango
Copy link
Member

I think this PR doesn't fix anything, it just introduced a uid label(like propagationpolicy.karmada.io/uid) and annotations, like propagationpolicy.karmada.io/namespace.

This PR does not fix the create resource binding failed by DependenciesDistributor

Do you mean this PR missed the changes that should made for DependenciesDistributor?

@wu0407
Copy link
Contributor

wu0407 commented Aug 30, 2023

I misunderstood this PR and indeed missed a DependenciesDistributor

@RainbowMango
Copy link
Member

Can you help to show me the code?

@wu0407
Copy link
Contributor

wu0407 commented Aug 31, 2023

func buildAttachedBinding(binding *workv1alpha2.ResourceBinding, object *unstructured.Unstructured) *workv1alpha2.ResourceBinding {
dependedLabels := generateBindingDependedLabels(binding.Namespace, binding.Name)
var result []workv1alpha2.BindingSnapshot
result = append(result, workv1alpha2.BindingSnapshot{
Namespace: binding.Namespace,
Name: binding.Name,
Clusters: binding.Spec.Clusters,
})
return &workv1alpha2.ResourceBinding{
ObjectMeta: metav1.ObjectMeta{
Name: names.GenerateBindingName(object.GetKind(), object.GetName()),
Namespace: binding.GetNamespace(),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(object, object.GroupVersionKind()),
},
Labels: dependedLabels,
Finalizers: []string{util.BindingControllerFinalizer},
},
Spec: workv1alpha2.ResourceBindingSpec{
Resource: workv1alpha2.ObjectReference{
APIVersion: object.GetAPIVersion(),
Kind: object.GetKind(),
Namespace: object.GetNamespace(),
Name: object.GetName(),
ResourceVersion: object.GetResourceVersion(),
},
RequiredBy: result,
},
}
}

@jwcesign
Copy link
Member Author

jwcesign commented Aug 31, 2023

I checked the code, there is no label about: propagationpolicy.karmada.io/xxx for dependency rb.

So it's two problems.

But indeed, there is a problem with too long label value(namesapce-63-char + rb-63-char):

labelValue := fmt.Sprintf(bindingNamespace + "_" + bindingName)

So in the next release, we will cut the label value as a hash, and the namespace and name information will be moved to annotation.

cc @wu0407
How do u think?

@wu0407
Copy link
Contributor

wu0407 commented Aug 31, 2023

is the next release 1.7?

@jwcesign
Copy link
Member Author

is the next release 1.7?

I think release-1.8,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants