karmada
karmada copied to clipboard
fix namespace already exist
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
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.
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.
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.
Now we have two approaches to solve this issue:
- Try to delete the etcd data during
deinitor initialize the etcd data path duringinit. - 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.
Now we have two approaches to solve this issue:
Try to delete the etcd data during
deinitor initialize the etcd data path duringinit.Try to blind the error by using the
create or updateThe 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".
I'd like the first too.Such like "kubeadm reset".
Yes, just make a clean base for the next init.
Sorry for delay @cleverhu , I will review ASAP.
/assign
@lonelyCZ I have updated the code, /PTAL.
Codecov Report
Merging #2505 (98b6b44) into master (900a1bb) will decrease coverage by
0.01%. The diff coverage is0.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.
Hi, @cleverhu , could you please help to resolve the conflicts? BTW, we have moved all CreateOrUpdateXXX functions to pkg/karmadactl/util/idempotency.go
Hi, @cleverhu , could you please help to resolve the conflicts? BTW, we have moved all
CreateOrUpdateXXXfunctions topkg/karmadactl/util/idempotency.go
Ok,I will update the code later.
[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.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
@lonelyCZ I have updated the code,PTAL.
It works well in my env.
/lgtm /approve
[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
- ~~pkg/karmadactl/OWNERS~~ [lonelyCZ]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/kind bug