From 1593e2adf658e048d1328852dd2158fd0e09daa0 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 9 Mar 2022 10:47:19 -0500 Subject: [PATCH] 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. --- nomad/job_endpoint.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index d6ab29058..b0ab7a95f 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -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))