From 389dff42a111ef09b2314385a4c436eea52847c6 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Tue, 30 May 2023 11:08:49 -0400 Subject: [PATCH] cli: fix panic on job restart (#17346) When monitoring the replacement allocation, if the `Allocations().Info()` request fails, the `alloc` variable is `nil`, so it should not be read. --- .changelog/17346.txt | 3 +++ command/job_restart.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .changelog/17346.txt diff --git a/.changelog/17346.txt b/.changelog/17346.txt new file mode 100644 index 000000000..660d7a32a --- /dev/null +++ b/.changelog/17346.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fix a panic in the `nomad job restart` command when monitoring replacement allocations +``` diff --git a/command/job_restart.go b/command/job_restart.go index 33f8b183f..ae5b61772 100644 --- a/command/job_restart.go +++ b/command/job_restart.go @@ -1045,7 +1045,7 @@ func (c *JobRestartCommand) monitorReplacementAlloc( alloc, qm, err := c.client.Allocations().Info(currentAllocID, q) if err != nil { - errCh <- fmt.Errorf("Failed to retrieve allocation %q: %w", limit(alloc.ID, c.length), err) + errCh <- fmt.Errorf("Failed to retrieve allocation %q: %w", limit(currentAllocID, c.length), err) return }