Skip to content

Commit

Permalink
add logs and confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Nov 18, 2021
1 parent f01cb50 commit 533a951
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/cluster/operation/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ func DestroyClusterTombstone(

if forcePDEndpoints != "" {
pdEndpoints = strings.Split(forcePDEndpoints, ",")
log.Warnf("%s is set, using %s as PD endpoints", EnvNamePDEndpointOverwrite, pdEndpoints)
} else {
pdEndpoints = cluster.GetPDList()
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/cluster/operation/scale_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/pingcap/tiup/pkg/logger/log"
"github.com/pingcap/tiup/pkg/proxy"
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/tui"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -116,7 +117,12 @@ func ScaleInCluster(
skipTopoCheck = true
}

if !skipTopoCheck {
if skipTopoCheck {
log.Warnf("%s is set, topology checks ignored, the cluster might be broken after the operations!", EnvNameSkipScaleInTopoCheck)
if ok, input := tui.PromptForConfirmYes("Are you sure to continue? [y/N]"); !ok {
return errors.Errorf("user aborted with '%s'", input)
}
} else {
// Cannot delete all PD servers
if len(deletedDiff[spec.ComponentPD]) == len(cluster.PDServers) {
return errors.New("cannot delete all PD servers")
Expand Down Expand Up @@ -151,6 +157,7 @@ func ScaleInCluster(

if forcePDEndpoints != "" {
pdEndpoints = strings.Split(forcePDEndpoints, ",")
log.Warnf("%s is set, using %s as PD endpoints", EnvNamePDEndpointOverwrite, pdEndpoints)
} else {
for _, instance := range (&spec.PDComponent{Topology: cluster}).Instances() {
if !deletedNodes.Exist(instance.ID()) {
Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/operation/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Upgrade(
case spec.ComponentTiKV:
if forcePDEndpoints != "" {
pdEndpoints = strings.Split(forcePDEndpoints, ",")
log.Warnf("%s is set, using %s as PD endpoints", EnvNamePDEndpointOverwrite, pdEndpoints)
} else {
pdEndpoints = topo.(*spec.Specification).GetPDList()
}
Expand Down

0 comments on commit 533a951

Please sign in to comment.