From b974c32ba64e4e14d79d4fd9c4c467f3c70223a2 Mon Sep 17 00:00:00 2001 From: Gabriel Villalonga Simon Date: Thu, 6 Oct 2022 21:23:22 +0100 Subject: [PATCH] Check that JobPlanResponse Diff Type is None before checking for changes on getExitCode (#14492) --- .changelog/14492.txt | 3 +++ command/job_plan.go | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 .changelog/14492.txt diff --git a/.changelog/14492.txt b/.changelog/14492.txt new file mode 100644 index 000000000..f3117baf5 --- /dev/null +++ b/.changelog/14492.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fixed a bug where plans for periodic jobs would return exit code 1 when the job was already register +``` \ No newline at end of file diff --git a/command/job_plan.go b/command/job_plan.go index 76a224ecc..7f71295cc 100644 --- a/command/job_plan.go +++ b/command/job_plan.go @@ -391,6 +391,10 @@ type namespaceIdPair struct { // * 0: No allocations created or destroyed. // * 1: Allocations created or destroyed. func getExitCode(resp *api.JobPlanResponse) int { + if resp.Diff.Type == "None" { + return 0 + } + // Check for changes for _, d := range resp.Annotations.DesiredTGUpdates { if d.Stop+d.Place+d.Migrate+d.DestructiveUpdate+d.Canary > 0 {