cli: Fix a panic in `deployment status` when scheduling is slow (#16011)

If a deployment fails, the `deployment status` command can get a nil deployment
when it checks for a rollback deployment if there isn't one (or at least not one
at the time of the query). Fix the panic.
This commit is contained in:
Tim Gross 2023-02-02 12:34:44 -05:00 committed by GitHub
parent 5f3bb0b197
commit 971a286ea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

3
.changelog/16011.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
cli: Fixed a panic in `deployment status` when rollback deployments are slow to appear
```

View File

@ -332,7 +332,7 @@ UPDATE:
// TODO We may want to find a more robust way of waiting for rollbacks to launch instead of
// just sleeping for 1 sec. If scheduling is slow, this will break update here instead of
// waiting for the (eventual) rollback
if rollback.ID == deploy.ID {
if rollback == nil || rollback.ID == deploy.ID {
break UPDATE
}
@ -441,7 +441,7 @@ func (c *DeploymentStatusCommand) defaultMonitor(client *api.Client, deployID st
// TODO We may want to find a more robust way of waiting for rollbacks to launch instead of
// just sleeping for 1 sec. If scheduling is slow, this will break update here instead of
// waiting for the (eventual) rollback
if rollback.ID == deploy.ID {
if rollback == nil || rollback.ID == deploy.ID {
return
}
c.defaultMonitor(client, rollback.ID, index, wait, verbose)