Improve handling of pause/unpause/stop/delete steps
parent
ac1f901160
commit
aa3d2a2a8a
|
@ -149,6 +149,8 @@ func runDelete(cmd *cobra.Command, args []string) {
|
|||
deleteContainersAndVolumes(oci.Podman)
|
||||
|
||||
errs := DeleteProfiles(profilesToDelete)
|
||||
register.Reg.SetStep(register.Done)
|
||||
|
||||
if len(errs) > 0 {
|
||||
HandleDeletionErrors(errs)
|
||||
} else {
|
||||
|
@ -169,6 +171,8 @@ func runDelete(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
errs := DeleteProfiles([]*config.Profile{profile})
|
||||
register.Reg.SetStep(register.Done)
|
||||
|
||||
if len(errs) > 0 {
|
||||
HandleDeletionErrors(errs)
|
||||
}
|
||||
|
|
|
@ -62,7 +62,13 @@ func runPause(cmd *cobra.Command, args []string) {
|
|||
ids := []string{}
|
||||
|
||||
for _, n := range co.Config.Nodes {
|
||||
out.T(out.Pause, "Pausing node {{.name}} ... ", out.V{"name": n.Name})
|
||||
// Use node-name if available, falling back to cluster name
|
||||
name := n.Name
|
||||
if n.Name == "" {
|
||||
name = co.Config.Name
|
||||
}
|
||||
|
||||
out.T(out.Pause, "Pausing node {{.name}} ... ", out.V{"name": name})
|
||||
|
||||
host, err := machine.LoadHost(co.API, driver.MachineName(*co.Config, n))
|
||||
if err != nil {
|
||||
|
|
|
@ -447,7 +447,7 @@ func clusterState(sts []*Status) ClusterState {
|
|||
case string(register.InitialSetup):
|
||||
transientCondition = Starting
|
||||
case string(register.Done):
|
||||
transientCondition = OK
|
||||
transientCondition = ""
|
||||
case string(register.Stopping):
|
||||
transientCondition = Stopping
|
||||
case string(register.Deleting):
|
||||
|
|
|
@ -78,6 +78,9 @@ func runStop(cmd *cobra.Command, args []string) {
|
|||
cname := ClusterFlagValue()
|
||||
profilesToStop = append(profilesToStop, cname)
|
||||
}
|
||||
|
||||
stoppedNodes := 0
|
||||
|
||||
for _, profile := range profilesToStop {
|
||||
register.Reg.SetStep(register.Stopping)
|
||||
|
||||
|
@ -87,10 +90,10 @@ func runStop(cmd *cobra.Command, args []string) {
|
|||
|
||||
for _, n := range cc.Nodes {
|
||||
machineName := driver.MachineName(*cc, n)
|
||||
nonexistent := stop(api, machineName)
|
||||
|
||||
nonexistent := stop(api, machineName)
|
||||
if !nonexistent {
|
||||
out.T(out.Stopped, `Node "{{.node_name}}" stopped.`, out.V{"node_name": machineName})
|
||||
stoppedNodes += 1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,8 +105,11 @@ func runStop(cmd *cobra.Command, args []string) {
|
|||
exit.WithError("update config", err)
|
||||
}
|
||||
}
|
||||
register.Reg.SetStep(register.Done)
|
||||
|
||||
register.Reg.SetStep(register.Done)
|
||||
if stoppedNodes > 0 {
|
||||
out.T(out.Stopped, `{{.count}} nodes stopped.`, out.V{"count": stoppedNodes})
|
||||
}
|
||||
}
|
||||
|
||||
func stop(api libmachine.API, machineName string) bool {
|
||||
|
|
|
@ -59,7 +59,14 @@ var unpauseCmd = &cobra.Command{
|
|||
|
||||
for _, n := range co.Config.Nodes {
|
||||
glog.Infof("node: %+v", n)
|
||||
out.T(out.Pause, "Unpausing node {{.name}} ... ", out.V{"name": n.Name})
|
||||
|
||||
// Use node-name if available, falling back to cluster name
|
||||
name := n.Name
|
||||
if n.Name == "" {
|
||||
name = co.Config.Name
|
||||
}
|
||||
|
||||
out.T(out.Pause, "Unpausing node {{.name}} ... ", out.V{"name": name})
|
||||
|
||||
machineName := driver.MachineName(*co.Config, n)
|
||||
host, err := machine.LoadHost(co.API, machineName)
|
||||
|
|
|
@ -41,7 +41,7 @@ func StopHost(api libmachine.API, machineName string) error {
|
|||
return errors.Wrapf(err, "load")
|
||||
}
|
||||
|
||||
out.T(out.Stopping, `Stopping "{{.profile_name}}" in {{.driver_name}} ...`, out.V{"profile_name": machineName, "driver_name": h.DriverName})
|
||||
out.T(out.Stopping, `Stopping node "{{.name}}" ...`, out.V{"name": machineName})
|
||||
return stop(h)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue