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

feat: add --purge-namespace flags for karmadactl deinit, and default not delete namespace #3326

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

my-git9
Copy link
Member

@my-git9 my-git9 commented Mar 24, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
karmadactl deinit will delete the namespace where karmda components are located.
In some cases, this processing is too rough, which may delete other resources created by the user under the namespace (the user does not want to be cleaned up together), such as imagepullsecret, Qos settings, etc.
If the user is given the opportunity to choose whether to clean up the entire namespace, it will have a better experience.

Does this PR introduce a user-facing change?:

`karmadactl`: Introduced `--purge-namespace` flag for `deinit` command to skip namespace deletion during uninstallation.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 24, 2023
@karmada-bot karmada-bot requested review from carlory and lonelyCZ March 24, 2023 04:19
@karmada-bot karmada-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 24, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2023

Codecov Report

Merging #3326 (fe6febb) into master (a14d64f) will increase coverage by 2.56%.
The diff coverage is n/a.

📣 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    #3326      +/-   ##
==========================================
+ Coverage   49.13%   51.69%   +2.56%     
==========================================
  Files         209      210       +1     
  Lines       18754    18931     +177     
==========================================
+ Hits         9214     9787     +573     
+ Misses       9039     8618     -421     
- Partials      501      526      +25     
Flag Coverage Δ
unittests 51.69% <ø> (+2.56%) ⬆️

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

see 45 files with indirect coverage changes

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

@my-git9
Copy link
Member Author

my-git9 commented Mar 24, 2023

The test result:

  • Init Karmada:

image

  • Create secret in karmada-system ns:

image

  • Deinit karmada with --ignore-namespace

image

  • Check

image

@@ -81,6 +82,7 @@ func NewCmdDeInit(parentCommand string) *cobra.Command {
flags.StringVar(&opts.Context, "context", "", "The name of the kubeconfig context to use")
flags.BoolVar(&opts.DryRun, "dry-run", false, "Run the command in dry-run mode, without making any server requests.")
flags.BoolVarP(&opts.Force, "force", "f", false, "Reset cluster without prompting for confirmation.")
flags.BoolVar(&opts.IgnoreNamespace, "ignore-namespace", false, "Reset cluster without delete namespace.")
Copy link
Member

Choose a reason for hiding this comment

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

The flag name ignore-namespace might be ambiguous, since deinit is going to uninstall/remove components from a cluster. ignore-namespace can be misinterpreted as if the component in the namespace, then ignore(cancel the process). What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is indeed a question, what do you think of the flag name no-delete-namespace?

Copy link
Member

Choose a reason for hiding this comment

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

Before talking about the flag name, I'd like to invite owners(@carlory @lonelyCZ ) to comment if this is a reasonable feature.

Copy link
Member

Choose a reason for hiding this comment

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

--preserve-resources ?

Copy link
Member

Choose a reason for hiding this comment

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

For security and more intuitive, I think we could let users determine if remove the namespace. Like

deinit will not delete etcd data, if the etcd data is persistent, please delete it yourself.
the default persistence path for etcd data is '/var/lib/karmada-etcd'

Or we simply don't delete the namespace

A option seems not to prevent mis-deleting for new users, because it is often missed. Based on this point, we shouldn't delete namespace by default.

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mybe we can not delete namespace by default, and delete namespace by specify options --purge-namespace ?

Copy link
Member

Choose a reason for hiding this comment

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

kindly ping @lonelyCZ @my-git9, do we have an executive decision?

Copy link
Member

Choose a reason for hiding this comment

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

For security and more intuitive, I think we could let users determine if remove the namespace. Like

+1, istio does not delete istio-system namespace when it is uninstalled by istioctl

Copy link
Member

Choose a reason for hiding this comment

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

Mybe we can not delete namespace by default, and delete namespace by specify options --purge-namespace ?

I think it is ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mybe we can not delete namespace by default, and delete namespace by specify options --purge-namespace ?

I adjusted PR in this way, and the test result:
image

@calvin0327
Copy link

If there are other workloads in the namespace karmada-system before installing karmada with karmadactl, It,s dangerous to delete the namespace.

@my-git9 my-git9 changed the title feat: add --ignore-namespace flags for karmadactl deinit feat: add --purge-namespace flags for karmadactl deinit, and default not delete namespace Apr 4, 2023
`karmada deinit` default not delete namespace

Signed-off-by: xin.li <xin.li@daocloud.io>
@hzxuzhonghu
Copy link
Member

/lgtm

@lonelyCZ can you approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2023
@lonelyCZ
Copy link
Member

lonelyCZ commented Apr 6, 2023

Thanks @my-git9

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu, 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 karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2023
@karmada-bot karmada-bot merged commit 31b5088 into karmada-io:master Apr 6, 2023
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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants