From bdb71e70741b6bcb6ef52f7567fc147472d6213d Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 19 Jul 2017 13:34:24 -0700 Subject: [PATCH] Small fixes and UX changes --- command/deployment_fail.go | 2 +- command/deployment_promote.go | 20 ++++++-------------- command/deployment_status.go | 9 +++++++-- nomad/deployment_endpoint.go | 6 +++++- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/command/deployment_fail.go b/command/deployment_fail.go index 543641e14..1b32540ef 100644 --- a/command/deployment_fail.go +++ b/command/deployment_fail.go @@ -42,7 +42,7 @@ func (c *DeploymentFailCommand) Synopsis() string { func (c *DeploymentFailCommand) Run(args []string) int { var detach, verbose bool - flags := c.Meta.FlagSet("deployment resume", FlagSetClient) + flags := c.Meta.FlagSet("deployment fail", FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } flags.BoolVar(&detach, "detach", false, "") flags.BoolVar(&verbose, "verbose", false, "") diff --git a/command/deployment_promote.go b/command/deployment_promote.go index 211211646..aa214f2d2 100644 --- a/command/deployment_promote.go +++ b/command/deployment_promote.go @@ -30,12 +30,9 @@ General Options: Promote Options: - -all - All promotes all task groups in the deployment. - -group Group may be specified many times and is used to promote that particular - group. + group. If no specific groups are specified, all groups are promoted. -detach Return immediately instead of entering monitor mode. After deployment @@ -49,16 +46,15 @@ Promote Options: } func (c *DeploymentPromoteCommand) Synopsis() string { - return "Manually fail a deployment" + return "Promote canaries in a deployment" } func (c *DeploymentPromoteCommand) Run(args []string) int { - var all, detach, verbose bool + var detach, verbose bool var groups []string - flags := c.Meta.FlagSet("deployment resume", FlagSetClient) + flags := c.Meta.FlagSet("deployment promote", FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } - flags.BoolVar(&all, "all", false, "") flags.BoolVar(&detach, "detach", false, "") flags.BoolVar(&verbose, "verbose", false, "") flags.Var((*flaghelper.StringFlag)(&groups), "group", "") @@ -73,10 +69,6 @@ func (c *DeploymentPromoteCommand) Run(args []string) int { c.Ui.Error(c.Help()) return 1 } - if !all && len(groups) == 0 { - c.Ui.Error("Either -all or one or more -group flags must be specified.") - return 1 - } dID := args[0] // Truncate the id unless full length is requested @@ -105,14 +97,14 @@ func (c *DeploymentPromoteCommand) Run(args []string) int { } var u *api.DeploymentUpdateResponse - if all { + if len(groups) == 0 { u, _, err = client.Deployments().PromoteAll(deploy.ID, nil) } else { u, _, err = client.Deployments().PromoteGroups(deploy.ID, groups, nil) } if err != nil { - c.Ui.Error(fmt.Sprintf("Error failing deployment: %s", err)) + c.Ui.Error(fmt.Sprintf("Error promoting deployment: %s", err)) return 1 } diff --git a/command/deployment_status.go b/command/deployment_status.go index 858ae4668..32302af03 100644 --- a/command/deployment_status.go +++ b/command/deployment_status.go @@ -177,9 +177,12 @@ func formatDeploymentGroups(d *api.Deployment, uuidLength int) string { if autorevert { rowString += "Auto Revert|" } + if canaries { + rowString += "Promoted|" + } rowString += "Desired|" if canaries { - rowString += "Canaries|Promoted|" + rowString += "Canaries|" } rowString += "Placed|Healthy|Unhealthy" @@ -191,10 +194,12 @@ func formatDeploymentGroups(d *api.Deployment, uuidLength int) string { if autorevert { row += fmt.Sprintf("%v|", state.AutoRevert) } + if canaries { + row += fmt.Sprintf("%v|", state.Promoted) + } row += fmt.Sprintf("%d|", state.DesiredTotal) if canaries { row += fmt.Sprintf("%d|", state.DesiredCanaries) - row += fmt.Sprintf("%v|", state.Promoted) } row += fmt.Sprintf("%d|%d|%d", state.PlacedAllocs, state.HealthyAllocs, state.UnhealthyAllocs) rows[i] = row diff --git a/nomad/deployment_endpoint.go b/nomad/deployment_endpoint.go index 98b03d734..731c5e71f 100644 --- a/nomad/deployment_endpoint.go +++ b/nomad/deployment_endpoint.go @@ -122,7 +122,11 @@ func (d *Deployment) Pause(args *structs.DeploymentPauseRequest, reply *structs. } if !deploy.Active() { - return fmt.Errorf("can't pause terminal deployment") + if args.Pause { + return fmt.Errorf("can't pause terminal deployment") + } + + return fmt.Errorf("can't resume terminal deployment") } // Call into the deployment watcher