From 895eee5489b093767415cdfb960b4e8b1908e815 Mon Sep 17 00:00:00 2001 From: Daniel Bennett Date: Tue, 3 Oct 2023 17:03:20 +0000 Subject: [PATCH] backport of commit e7136f80c5c1277ea2dea4eeeda84005224d7835 --- .changelog/18637.txt | 3 +++ nomad/job_endpoint.go | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changelog/18637.txt diff --git a/.changelog/18637.txt b/.changelog/18637.txt new file mode 100644 index 00000000000..aaa01ad4a5f --- /dev/null +++ b/.changelog/18637.txt @@ -0,0 +1,3 @@ +```release-note:bug +scaling: Unblock blocking queries to /v1/job/{job-id}/scale if the job goes away +``` diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index 9f88bf71d3d..9e7197d42a2 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -2156,8 +2156,13 @@ func (j *Job) ScaleStatus(args *structs.JobScaleStatusRequest, return err } if job == nil { + // HTTPServer.jobScaleStatus() will 404 if this is nil reply.JobScaleStatus = nil - return nil + + // reply with latest index, since if the job does get created, + // it must necessarily be later than current latest. + reply.Index, err = state.LatestIndex() + return err } events, eventsIndex, err := state.ScalingEventsByJob(ws, args.RequestNamespace(), args.JobID)