Skip to content

Commit

Permalink
cluster: add significant warning destroying a cluster (#1723)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis authored Jan 14, 2022
1 parent 7bfbed1 commit ff446c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions pkg/cluster/manager/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ func (m *Manager) DestroyCluster(name string, gOpt operator.Options, destroyOpt
}

if !skipConfirm {
if err := tui.PromptForConfirmOrAbortError(
"This operation will destroy %s %s cluster %s and its data.\nDo you want to continue? [y/N]:",
m.sysName,
color.HiYellowString(base.Version),
color.HiYellowString(name)); err != nil {
m.logger.Warnf(color.HiRedString(tui.ASCIIArtWarning))
if err := tui.PromptForAnswerOrAbortError(
"Yes, I know my cluster and data will be deleted.",
fmt.Sprintf("This operation will destroy %s %s cluster %s and its data.",
m.sysName,
color.HiYellowString(base.Version),
color.HiYellowString(name),
)+"\nAre you sure to continue?",
); err != nil {
return err
}
m.logger.Infof("Destroying cluster...")
Expand Down
2 changes: 1 addition & 1 deletion tests/tiup-cluster/script/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ EOEX

tiup-cluster _test $name writable

yes | tiup-cluster destroy $name
tiup-cluster --yes destroy $name
}
2 changes: 1 addition & 1 deletion tests/tiup-dm/test_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ tiup-dm exec $name -N "$ipprefix.104:8261" --command "grep '31s' /home/tidb/depl
./script/task/run.sh


yes | tiup-dm destroy $name
tiup-dm --yes destroy $name

0 comments on commit ff446c1

Please sign in to comment.