Manager & Webapp: code changes to handle the new worker tag info in Job

Manager: Instead of embedding the worker tag info in a fetched `Job`,
just include its UUID.

Webapp: fetch the worker tag by UUID, instead of using the embedded
info.
This commit is contained in:
Sybren A. Stüvel 2024-07-30 11:03:02 +02:00
parent 2f4124ebc2
commit 8f9ed0cc28
4 changed files with 4 additions and 13 deletions

View File

@ -687,7 +687,7 @@ func jobDBtoAPI(dbJob *persistence.Job) api.Job {
apiJob.DeleteRequestedAt = &dbJob.DeleteRequestedAt.Time apiJob.DeleteRequestedAt = &dbJob.DeleteRequestedAt.Time
} }
if dbJob.WorkerTag != nil { if dbJob.WorkerTag != nil {
apiJob.WorkerTag = workerTagDBtoAPI(dbJob.WorkerTag) apiJob.WorkerTag = &dbJob.WorkerTag.UUID
} }
return apiJob return apiJob

View File

@ -130,14 +130,10 @@ func TestFetchJob(t *testing.T) {
Metadata: &api.JobMetadata{AdditionalProperties: map[string]string{ Metadata: &api.JobMetadata{AdditionalProperties: map[string]string{
"project": "/projects/exploding-kittens", "project": "/projects/exploding-kittens",
}}, }},
WorkerTag: ptr("d86e1b84-5ee2-4784-a178-65963eeb484b"),
}, },
Id: "afc47568-bd9d-4368-8016-e91d945db36d", Id: "afc47568-bd9d-4368-8016-e91d945db36d",
Status: api.JobStatusActive, Status: api.JobStatusActive,
WorkerTag: &api.WorkerTag{
Id: ptr("d86e1b84-5ee2-4784-a178-65963eeb484b"),
Name: "Tikkie terug Kees!",
Description: nil, // Empty description should just be excluded from the JSON.
},
} }
assertResponseJSON(t, echoCtx, http.StatusOK, expectedJob) assertResponseJSON(t, echoCtx, http.StatusOK, expectedJob)

View File

@ -415,11 +415,6 @@ func TestSubmitJobWithWorkerTag(t *testing.T) {
DeleteRequestedAt: nil, DeleteRequestedAt: nil,
Activity: "", Activity: "",
Status: api.JobStatusQueued, Status: api.JobStatusQueued,
WorkerTag: &api.WorkerTag{
Id: ptr(workerTagUUID),
Name: "first tag",
Description: ptr("my first tag"),
},
}) })
} }

View File

@ -46,8 +46,8 @@
<dd>{{ jobType ? jobType.label : jobData.type }}</dd> <dd>{{ jobType ? jobType.label : jobData.type }}</dd>
<dt class="field-worker-tag" title="Worker Tag">Worker Tag</dt> <dt class="field-worker-tag" title="Worker Tag">Worker Tag</dt>
<dd v-if="jobData.worker_tag" :title="jobData.worker_tag.description"> <dd v-if="workerTag" :title="workerTag.description">
{{ jobData.worker_tag.name }} {{ workerTag.name }}
</dd> </dd>
<dd v-else class="no-worker-tag">All Workers</dd> <dd v-else class="no-worker-tag">All Workers</dd>