backport of commit e7136f80c5c1277ea2dea4eeeda84005224d7835 (#18648)

Co-authored-by: Daniel Bennett <dbennett@hashicorp.com>
This commit is contained in:
hc-github-team-nomad-core 2023-10-03 12:27:26 -05:00 committed by GitHub
parent 5147682d40
commit ce6c86a057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

3
.changelog/18637.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
scaling: Unblock blocking queries to /v1/job/{job-id}/scale if the job goes away
```

View File

@ -2209,8 +2209,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)