-
Notifications
You must be signed in to change notification settings - Fork 216
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
[kwokctl] Support Force Delete Cluster #1128
Conversation
Hi @joeyyy09. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
✅ Deploy Preview for k8s-kwok canceled.
|
/ok-to-test |
Hey @wzshiming, I've made the required changes, can you please let me know if i've got to change anything else? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/pkg/kwokctl/cmd/delete/cluster/cluster.go b/pkg/kwokctl/cmd/delete/cluster/cluster.go
index 7530a260..571dbefd 100644
--- a/pkg/kwokctl/cmd/delete/cluster/cluster.go
+++ b/pkg/kwokctl/cmd/delete/cluster/cluster.go
@@ -35,9 +35,10 @@ import (
type flagpole struct {
Name string
Kubeconfig string
+ Force bool
}
-// NewCommand returns a new cobra.Command for cluster creation
+// NewCommand returns a new cobra.Command for cluster deletion
func NewCommand(ctx context.Context) *cobra.Command {
flags := &flagpole{}
flags.Kubeconfig = path.RelFromHome(kubeconfig.GetRecommendedKubeconfigPath())
@@ -52,6 +53,7 @@ func NewCommand(ctx context.Context) *cobra.Command {
},
}
cmd.Flags().StringVar(&flags.Kubeconfig, "kubeconfig", flags.Kubeconfig, "The path to the kubeconfig file that will remove the deleted cluster")
+ cmd.Flags().BoolVar(&flags.Force, "force", false, "Force delete the cluster")
return cmd
}
@@ -77,6 +79,13 @@ func runE(ctx context.Context, flags *flagpole) error {
return err
}
+ if err := rt.Available(ctx); err != nil {
+ if !flags.Force {
+ return err
+ }
+ logger.Warn("Unavailable runtime but proceed with force delete", "err", err)
+ }
+
// Stop the cluster
start := time.Now()
logger.Info("Cluster is stopping")
This needs rebase. |
I think the changes made in this PR have been made in #1125 and has been merged. |
So now you need to rebase this branch to the main. |
Made the changes |
NOTICE THIS PATCH |
Yeah, should i modify anything here? |
Your changes are wrong. |
Okay, I'll rethink my approach and will fix this. |
It cannot achieve the effect of not forcing deletion |
Normal deletion works normal when the --force flag is not set and the runtime is available. If the runtime is not available and the --force flag is not set, the cluster will not be deleted. If the --force flag is set to true, the cluster will be deleted despite the unavailability of the runtime. Is this correct? I was trying to implement this and i've checked with and without the flags on my local build. Can you please explain me in detail if this understanding of mine is wrong? |
Can't you see this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are too many irrelevant changes, please squash all commits
Signed-off-by: Joeyyy09 <[email protected]> Add check for runtime Signed-off-by: Joeyyy09 <[email protected]> Update docs Signed-off-by: Joeyyy09 <[email protected]> Rebase to main Signed-off-by: Joeyyy09 <[email protected]> Add force flag Signed-off-by: Joeyyy09 <[email protected]> Modify according to the patch Signed-off-by: Joeyyy09 <[email protected]>
Yep, squashed all the commits |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: joeyyy09, wzshiming 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR introduces a new --force flag for the kwokctl delete cluster command. This flag allows users to force delete a cluster, even if the runtime is unavailable or the cluster does not exist.
Which issue(s) this PR fixes:
Fixes #1124
Special notes for your reviewer:
The main changes include:
Addition of the Force field in the flagpole struct.
Modification of the deleteCluster function to handle the force flag.
Addition of the --force command-line flag in the NewCommand function.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: