From b718fb0f79f1d1fbacf7d26a27db1f6f4ccdc227 Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Mon, 6 Sep 2021 15:06:57 +0800 Subject: [PATCH] cluster: add `--force` argument for `prune` subcommand (#1552) --- components/cluster/command/prune.go | 2 ++ pkg/cluster/operation/destroy.go | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/cluster/command/prune.go b/components/cluster/command/prune.go index 16ef7a520a..26b67374be 100644 --- a/components/cluster/command/prune.go +++ b/components/cluster/command/prune.go @@ -34,5 +34,7 @@ func newPruneCmd() *cobra.Command { }, } + cmd.Flags().BoolVar(&gOpt.Force, "force", false, "Ignore errors when deleting the instance with data from the cluster") + return cmd } diff --git a/pkg/cluster/operation/destroy.go b/pkg/cluster/operation/destroy.go index 3e81bd86a4..705ce5a44b 100644 --- a/pkg/cluster/operation/destroy.go +++ b/pkg/cluster/operation/destroy.go @@ -488,7 +488,12 @@ func DestroyClusterTombstone( instCount[instance.GetHost()]-- err := StopAndDestroyInstance(ctx, cluster, instance, options, instCount[instance.GetHost()] == 0) if err != nil { - return err + if options.Force { + log.Warnf("failed to stop and destroy instance %s (%s), ignored as --force is set, you may need to manually cleanup the files", + instance, err) + } else { + return err + } } } return nil