From 5c5a7cd1a4ff2619b1857507d8ac3b75a9e81b0a Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 1 Feb 2023 14:43:13 -0500 Subject: [PATCH] cli: Fix a panic in `deployment status` when scheduling is slow 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. --- .changelog/16011.txt | 3 +++ command/deployment_status.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .changelog/16011.txt diff --git a/.changelog/16011.txt b/.changelog/16011.txt new file mode 100644 index 000000000000..9e0e4f23ca6d --- /dev/null +++ b/.changelog/16011.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fixed a panic in `deployment status` when rollback deployments are slow to appear +``` diff --git a/command/deployment_status.go b/command/deployment_status.go index bd526821409f..260f54bf0074 100644 --- a/command/deployment_status.go +++ b/command/deployment_status.go @@ -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)