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

Restrict the cluster sync mode for the unjoin and unregister command #6081

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

Conversation

zhzhuang-zju
Copy link
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:
Restrict the cluster sync mode for the unjoin and unregister command.

$ karmadactl get cluster
NAME      CLUSTER   VERSION   MODE   READY   AGE     ADOPTION
member1   Karmada   v1.31.2   Push   True    17h     -
member3   Karmada   v1.31.2   Pull   True    3d23h   -
$ karmadactl unregister member1  --cluster-kubeconfig ~/.kube/members.config --karmada-config ~/.kube/karmada.config --cluster-context member1 -v=4 
I0124 11:10:55.943833 2452252 unregister.go:188] Unregistering cluster. cluster name: member1
I0124 11:10:55.943887 2452252 unregister.go:189] Unregistering cluster. karmada-agent deployed in namespace: karmada-system
I0124 11:10:55.943901 2452252 unregister.go:190] Unregistering cluster. member cluster secrets stored in namespace: karmada-cluster
error: cluster member1 is a Push mode member cluster, please use command `unjoin` if you want to unregister cluster
$ karmadactl unjoin member3 --cluster-kubeconfig=/root/.kube/members.config --cluster-context=member3                                               
error: cluster member3 is a Pull mode member cluster, please use command `unregister` if you want to unregister cluster

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

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

`karmadactl`: The `unjoin` command is restricted to only unjoin push mode member clusters. The `unregister` command is restricted to only unregister pull mode member clusters.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 24, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chaunceyjiang for approval. For more information see the Kubernetes Code Review Process.

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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 24, 2025
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 38.46154% with 16 lines in your changes missing coverage. Please review.

Project coverage is 48.31%. Comparing base (3e3e8fe) to head (99d985a).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/karmadactl/util/cluster.go 0.00% 10 Missing ⚠️
pkg/karmadactl/unjoin/unjoin.go 62.50% 2 Missing and 1 partial ⚠️
pkg/karmadactl/unregister/unregister.go 62.50% 2 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6081      +/-   ##
==========================================
- Coverage   48.35%   48.31%   -0.05%     
==========================================
  Files         666      666              
  Lines       54874    54903      +29     
==========================================
- Hits        26535    26527       -8     
- Misses      26615    26645      +30     
- Partials     1724     1731       +7     
Flag Coverage Δ
unittests 48.31% <38.46%> (-0.05%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RainbowMango
Copy link
Member

error: cluster member1 is a Push mode member cluster, please use command unjoin if you want to unregister cluster
error: cluster member3 is a Pull mode member cluster, please use command unregister if you want to unregister cluster

No data was changed or removed before this log, right?

@zhzhuang-zju
Copy link
Contributor Author

No data was changed or removed before this log, right?

Yes, I put the validations ahead of the unjoin/unregister operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. 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.

karmadactl unjoin doesn't delete agent when unjoinning a pull mode cluster
4 participants