mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add provisioner daemon name to provisioner jobs responses (#17877)
# Description This PR adds the `worker_name` field to the provisioner jobs endpoint. To achieve this, the following SQL query was updated: - `GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner` As a result, the `codersdk.ProvisionerJob` type, which represents the provisioner job API response, was modified to include the new field. **Notes:** * As mentioned in [comment](https://github.com/coder/coder/pull/17877#discussion_r2093218206), the `GetProvisionerJobsByIDsWithQueuePosition` query was not changed due to load concerns. This means that for template and template version endpoints, `worker_id` will still be returned, but `worker_name` will not. * Similar to `worker_id`, the `worker_name` is only present once a job is assigned to a provisioner daemon. For jobs in a pending state (not yet assigned), neither `worker_id` nor `worker_name` will be returned. --- # Affected Endpoints - `/organizations/{organization}/provisionerjobs` - `/organizations/{organization}/provisionerjobs/{job}` --- # Testing - Added new tests verifying that both `worker_id` and `worker_name` are returned once a provisioner job reaches the **succeeded** state. - Existing tests covering state transitions and other logic remain unchanged, as they test different scenarios. --- # Front-end Changes Admin provisioner jobs dashboard: <img width="1088" alt="Screenshot 2025-05-16 at 11 51 33" src="https://github.com/user-attachments/assets/0e20e360-c615-4497-84b7-693777c5443e" /> Fixes: https://github.com/coder/coder/issues/16982
This commit is contained in:
@@ -4848,6 +4848,13 @@ func (q *FakeQuerier) GetProvisionerJobsByOrganizationAndStatusWithQueuePosition
|
||||
row.AvailableWorkers = append(row.AvailableWorkers, worker.ID)
|
||||
}
|
||||
}
|
||||
|
||||
// Add daemon name to provisioner job
|
||||
for _, daemon := range q.provisionerDaemons {
|
||||
if job.WorkerID.Valid && job.WorkerID.UUID == daemon.ID {
|
||||
row.WorkerName = daemon.Name
|
||||
}
|
||||
}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user