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

Revise binding/work naming #2969

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dddddai
Copy link
Member

@dddddai dddddai commented Dec 16, 2022

What type of PR is this?
/kind bug
/kind design

What this PR does / why we need it:
The current binding/work naming has some defects as mentioned in #2090 and #2099, this pr revises the naming rule to solve them

If name collision happens, we will append a random suffix to the name and retry again

Which issue(s) this PR fixes:
Fixes #2090 and #2099

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fixed binding/work name collision

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 16, 2022
@karmada-bot karmada-bot added the kind/design Categorizes issue or PR as related to design. label Dec 16, 2022
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign kevin-wangzefeng after the PR has been reviewed.
You can assign the PR to them by writing /assign @kevin-wangzefeng in a comment when ready.

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

@karmada-bot karmada-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 16, 2022
@dddddai dddddai marked this pull request as draft December 17, 2022 01:30
@karmada-bot karmada-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 17, 2022
@dddddai dddddai marked this pull request as ready for review December 21, 2022 09:25
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 21, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 21, 2022

Codecov Report

Merging #2969 (620f73f) into master (69d330f) will decrease coverage by 0.38%.
The diff coverage is 2.23%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #2969      +/-   ##
==========================================
- Coverage   49.27%   48.89%   -0.38%     
==========================================
  Files         203      203              
  Lines       18222    18366     +144     
==========================================
+ Hits         8978     8980       +2     
- Misses       8753     8895     +142     
  Partials      491      491              
Flag Coverage Δ
unittests 48.89% <2.23%> (-0.38%) ⬇️

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

Impacted Files Coverage Δ
pkg/controllers/binding/binding_controller.go 0.00% <0.00%> (ø)
...ers/binding/cluster_resource_binding_controller.go 0.00% <0.00%> (ø)
pkg/controllers/status/workstatus_controller.go 0.00% <0.00%> (ø)
pkg/detector/detector.go 0.00% <0.00%> (ø)
pkg/util/annotation.go 83.63% <0.00%> (-12.20%) ⬇️
pkg/util/helper/work.go 41.28% <0.00%> (-1.99%) ⬇️
pkg/util/names/names.go 40.39% <1.66%> (-56.08%) ⬇️
pkg/controllers/binding/common.go 25.71% <22.22%> (-0.76%) ⬇️
pkg/search/proxy/store/util.go 93.83% <0.00%> (+0.94%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@dddddai dddddai force-pushed the rb-name branch 2 times, most recently from 371cd13 to a4b5afc Compare December 22, 2022 07:10
Signed-off-by: dddddai <dddwq@foxmail.com>
@RainbowMango
Copy link
Member

Thanks @dddddai, I'll get back on this later, maybe after release 1.5.

@dddddai
Copy link
Member Author

dddddai commented Feb 27, 2023

OK, no rush :)

@RainbowMango
Copy link
Member

/assign

// GenerateBindingName will generate binding name by kind and name
func GenerateBindingName(kind, name string) string {
// GenerateBindingName will generate binding name for the template.
func GenerateBindingName(ctx context.Context, karmadaClient client.Client, dynamicClient dynamic.Interface,
Copy link
Member

Choose a reason for hiding this comment

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

Here(and the GenerateWorkName below) tells the main idea that identifying the conflicts and making a random name, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we will append a random suffix if there's a conlict, and record the name in resource template annotations

Copy link
Member

Choose a reason for hiding this comment

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

One of the advantages is that the mechanism can be shared with three controllers:

  1. build ResourceBinding by detector
  2. build ResourceBinding by dependenciesdistributor
  3. build ResourceBinding by hpa controller

But the disadvantage seems to be that GenerateBindingName is coupled with too much logic that beyond a function should do. And after we generated the ResourceBinding, we usually try to create or update it by controllerutil.CreateOrUpdate which will get the ResourceBinding one more time in addition to GenerateBindingName, that seems redundant.

In general, I like the idea that we can introduce an annotation to the resource template to record the conflict condition(just like Deployment CollisionCount) that could be a factor to build ResourceBinding name.

So, I'm thinking if there is a more elegant way to do this. I don't have a clue yet.
I'd like to invite @Garrybest @likakuli for comment.

Copy link
Member

Choose a reason for hiding this comment

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

100% agree. This function is much more complex than it should be. Introduce an anotation or an API field could be better.

Copy link
Member

Choose a reason for hiding this comment

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

agree. I think a new field like CollisionCount could be better.

Copy link
Member

Choose a reason for hiding this comment

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

@likakuli We can't change the API of any resource template, that's the reason why we are considering annotation.

@RainbowMango
Copy link
Member

I'm trying to figure out which PR/Issue should be included in the coming v1.7 release which is planned at the end of this month.
I guess we don't have enough time for this feature, so I'm moving this to v1.8.

@RainbowMango RainbowMango modified the milestones: v1.7, v1.8 Aug 25, 2023
@RainbowMango RainbowMango modified the milestones: v1.8, v1.9 Nov 30, 2023
@RainbowMango RainbowMango modified the milestones: v1.9, v1.10 Feb 29, 2024
@RainbowMango RainbowMango modified the milestones: v1.10, v1.11 May 29, 2024
@RainbowMango RainbowMango modified the milestones: v1.11, v1.12 Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/design Categorizes issue or PR as related to design. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RB may not be created when delete and create the same object immediately
6 participants