karmada icon indicating copy to clipboard operation
karmada copied to clipboard

fix namespace already exist

Open cleverhu opened this issue 3 years ago • 10 comments

What type of PR is this? Fix namespace already exists when use karmadactl init

What this PR does / why we need it:

Which issue(s) this PR fixes: Fixes https://github.com/karmada-io/karmada/issues/2504

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

None

cleverhu avatar Sep 11 '22 05:09 cleverhu

Do you know why we didn't remove the etcd data before?

Because we couldn't certain if schedule the etcd to master node of karmada-host. It could be scheduled to other node, but we don't execute deinit on this node.

lonelyCZ avatar Sep 15 '22 12:09 lonelyCZ

Because we couldn't certain if schedule the etcd to master node of karmada-host. It could be scheduled to other node, but we don't execute deinit on this node.

Oh, I see. Then we also have the same problem when we try to delete the legacy etcd. Isn't? Because we are not sure that the etcd was running on the current node before.

RainbowMango avatar Sep 15 '22 13:09 RainbowMango

Then we also have the same problem when we try to delete the legacy etcd. Isn't? Because we are not sure that the etcd was running on the current node before.

Yes.

lonelyCZ avatar Sep 15 '22 13:09 lonelyCZ

Now we have two approaches to solve this issue:

  1. Try to delete the etcd data during deinit or initialize the etcd data path during init.
  2. Try to blind the error by using the create or update

The disadvantage of the first approach is we can't guarantee the etcd data can be cleaned as we don't know if the data on the node where running the command.

The disadvantage of the second approach is it allows people to reuse the legacy etcd data which is probably not expected.

I prefer the first approach, even though it has its limitation. @cleverhu @lonelyCZ how do you say?

Also, ask @prodanlabs for comments.

RainbowMango avatar Sep 16 '22 07:09 RainbowMango

Now we have two approaches to solve this issue:

  1. Try to delete the etcd data during deinit or initialize the etcd data path during init.

  2. Try to blind the error by using the create or update

The disadvantage of the first approach is we can't guarantee the etcd data can be cleaned as we don't know if the data on the node where running the command.

The disadvantage of the second approach is it allows people to reuse the legacy etcd data which is probably not expected.

I prefer the first approach, even though it has its limitation.

@cleverhu @lonelyCZ how do you say?

Also, ask @prodanlabs for comments.

I'd like the first too.Such like "kubeadm reset".

cleverhu avatar Sep 16 '22 13:09 cleverhu

I'd like the first too.Such like "kubeadm reset".

Yes, just make a clean base for the next init.

RainbowMango avatar Sep 17 '22 04:09 RainbowMango

Sorry for delay @cleverhu , I will review ASAP.

/assign

lonelyCZ avatar Oct 17 '22 12:10 lonelyCZ

@lonelyCZ I have updated the code, /PTAL.

cleverhu avatar Oct 20 '22 04:10 cleverhu

Codecov Report

Merging #2505 (98b6b44) into master (900a1bb) will decrease coverage by 0.01%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2505      +/-   ##
==========================================
- Coverage   25.62%   25.61%   -0.02%     
==========================================
  Files         184      186       +2     
  Lines       18513    18521       +8     
==========================================
  Hits         4744     4744              
- Misses      13423    13431       +8     
  Partials      346      346              
Flag Coverage Δ
unittests 25.61% <0.00%> (-0.02%) :arrow_down:

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

Impacted Files Coverage Δ
pkg/karmadactl/cmdinit/kubernetes/namespace.go 0.00% <0.00%> (ø)
pkg/karmadactl/cmdinit/utils/namespace.go 0.00% <0.00%> (ø)
pkg/karmadactl/cmdinit/utils/rbac.go 0.00% <0.00%> (ø)
pkg/karmadactl/cmdinit/utils/service.go 0.00% <0.00%> (ø)
pkg/search/proxy/store/util.go 93.56% <0.00%> (ø)

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

codecov-commenter avatar Nov 03 '22 11:11 codecov-commenter

Hi, @cleverhu , could you please help to resolve the conflicts? BTW, we have moved all CreateOrUpdateXXX functions to pkg/karmadactl/util/idempotency.go

lonelyCZ avatar Nov 06 '22 14:11 lonelyCZ

Hi, @cleverhu , could you please help to resolve the conflicts? BTW, we have moved all CreateOrUpdateXXX functions to pkg/karmadactl/util/idempotency.go

Ok,I will update the code later.

cleverhu avatar Nov 07 '22 01:11 cleverhu

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please ask for approval from lonelycz after the PR has been reviewed.

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 avatar Nov 07 '22 09:11 karmada-bot

@lonelyCZ I have updated the code,PTAL.

cleverhu avatar Nov 07 '22 09:11 cleverhu

It works well in my env.

/lgtm /approve

lonelyCZ avatar Nov 13 '22 12:11 lonelyCZ

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lonelyCZ

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 avatar Nov 13 '22 12:11 karmada-bot

/kind bug

lonelyCZ avatar Nov 13 '22 12:11 lonelyCZ