job summary query in Job.List RPC should use job's namespace (#12249)

The `Job.List` RPC attaches a `JobSummary` to each job stub. We're
using the request namespace and not the job namespace for that query,
which results in a nil `JobSummary` whenever we pass the wildcard
namespace. This is incorrect and causes panics in downstream consumers
like the CLI, which assume the `JobSummary` is non-nil as an unstate
invariant.
This commit is contained in:
Tim Gross
2022-03-09 10:47:19 -05:00
committed by GitHub
parent 68b203f77f
commit 1593e2adf6

View File

@@ -1412,8 +1412,8 @@ func (j *Job) List(args *structs.JobListRequest, reply *structs.JobListResponse)
paginator, err := paginator.NewPaginator(iter, tokenizer, filters, args.QueryOptions,
func(raw interface{}) error {
job := raw.(*structs.Job)
summary, err := state.JobSummaryByID(ws, namespace, job.ID)
if err != nil {
summary, err := state.JobSummaryByID(ws, job.Namespace, job.ID)
if err != nil || summary == nil {
return fmt.Errorf("unable to look up summary for job: %v", job.ID)
}
jobs = append(jobs, job.Stub(summary))