From ca562a229d8a461d91f2d43400dc57ab28f19b70 Mon Sep 17 00:00:00 2001 From: Daniel Bennett Date: Mon, 2 Oct 2023 14:53:21 -0500 Subject: [PATCH 1/2] scaling: set Index on nil-job scale status reply returning a nil error in a blockingOptions.run() without increasing the reply Index can cause the query to block indefinitely (until timeout). this fixes that happening in Job.ScaleStatus when the job is deleted -- the job going away should now return as not-found and provide a new index for the caller to try if they so please. --- nomad/job_endpoint.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index bfa597693645..11552adc4ba3 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -2216,8 +2216,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) From 4fef819b69a92d6376ad650663de53428d139ed8 Mon Sep 17 00:00:00 2001 From: Daniel Bennett Date: Mon, 2 Oct 2023 15:10:53 -0500 Subject: [PATCH 2/2] changelog for #18637 --- .changelog/18637.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/18637.txt diff --git a/.changelog/18637.txt b/.changelog/18637.txt new file mode 100644 index 000000000000..aaa01ad4a5ff --- /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 +```