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

avoid joining the same cluster repeatedly #2369

Merged
merged 1 commit into from
Aug 19, 2022

Conversation

yy158775
Copy link
Contributor

@yy158775 yy158775 commented Aug 12, 2022

Signed-off-by: yy158775 1584616775@qq.com

What type of PR is this?
/kind bug

What this PR does / why we need it:
prevent the same cluster repeating to join karmada.

Which issue(s) this PR fixes:
Fixes #1351

Special notes for your reviewer:

The same cluster repeatedly join has two scenarios.
One is use karmadactl to join push mode cluster.

Before join,the cluster member1,member2,member3 has joined in karmada.
Now we use member4 as the cluster's name to join the member1's cluster to control plane.

karmadactl join member4 --cluster-kubeconfig=~/.kube/members.config --cluster-context=member1

Results:
error: failed to create cluster(member4) object. error: cluster(id:fc1c4701-34c9-4a4b-afc2-296ecefe0c2d) already exist

The other is use karmada-agent to join pull mode cluster.
Results:

│ E0812 09:31:16.363961       1 agent.go:375] Failed to create cluster(member6) object, error: cluster(id:fc1c4701-34c9-4a4b-afc2-296ecefe0c2d) already exist                       │
│ E0812 09:31:16.363991       1 run.go:74] "command failed" err="failed to register with karmada control plane: cluster(id:fc1c4701-34c9-4a4b-afc2-296ecefe0c2d) already exist"
Then the pod turns into crashed.

Does this PR introduce a user-facing change?:

`karmada-agent`/`karmadactl`: Now an error will be raised when registering the same cluster to Karmada.

@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 12, 2022
@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 12, 2022
@yy158775 yy158775 changed the title solve the same cluster repeat join prevent the same cluster from joining repeatedly Aug 12, 2022
@yy158775 yy158775 changed the title prevent the same cluster from joining repeatedly avoid joining the same cluster repeatedly Aug 12, 2022
@yy158775 yy158775 force-pushed the id_join branch 2 times, most recently from b63ed62 to 765635f Compare August 15, 2022 06:20
pkg/util/cluster.go Outdated Show resolved Hide resolved
pkg/util/cluster.go Outdated Show resolved Hide resolved
@yy158775 yy158775 force-pushed the id_join branch 4 times, most recently from 2f81f7a to da89022 Compare August 15, 2022 11:39
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang 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 15, 2022
}

if !ok {
return fmt.Errorf("cluster(id):%s already exist", id)
Copy link
Member

Choose a reason for hiding this comment

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

error: failed to create cluster(member4) object. error: cluster(id:fc1c4701-34c9-4a4b-afc2-296ecefe0c2d) already exist

This log doesn't clear enough for users to understand what happened.
The log should be The same cluster has been registered with name xxxx

@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 17, 2022
@yy158775 yy158775 force-pushed the id_join branch 2 times, most recently from 13df04e to d879d24 Compare August 17, 2022 03:30
Signed-off-by: yy158775 <1584616775@qq.com>
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.

/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 19, 2022
@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 19, 2022
@karmada-bot karmada-bot merged commit 674641c into karmada-io:master Aug 19, 2022
This pull request was closed.
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/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a cluster can be joined to mulit karmada instance or be joined to the same karmada with different names
4 participants