Skip to content

Commit 58d0234

Browse files
committed
fix: limit worker_name addition to GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisioner query
1 parent 5fc39a0 commit 58d0234

File tree

6 files changed

+3
-300
lines changed

6 files changed

+3
-300
lines changed

cli/testdata/coder_list_--output_json.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"completed_at": "====[timestamp]=====",
3838
"status": "succeeded",
3939
"worker_id": "====[workspace build worker ID]=====",
40-
"worker_name": "test-daemon",
4140
"file_id": "=====[workspace build file ID]======",
4241
"tags": {
4342
"owner": "",

coderd/database/dbmem/dbmem.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,14 +1267,6 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedTagBasedQueu
12671267
// Step 6: Compute the final results with minimal checks
12681268
var results []database.GetProvisionerJobsByIDsWithQueuePositionRow
12691269
for _, job := range filteredJobs {
1270-
workerName := ""
1271-
// Add daemon name to provisioner job
1272-
for _, daemon := range q.provisionerDaemons {
1273-
if job.WorkerID.Valid && job.WorkerID.UUID == daemon.ID {
1274-
workerName = daemon.Name
1275-
}
1276-
}
1277-
12781270
// If the job has a computed rank, use it
12791271
if rank, found := jobQueueStats[job.ID]; found {
12801272
results = append(results, rank)
@@ -1286,7 +1278,6 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedTagBasedQueu
12861278
ProvisionerJob: job,
12871279
QueuePosition: 0,
12881280
QueueSize: 0,
1289-
WorkerName: workerName,
12901281
})
12911282
}
12921283
}

coderd/database/queries.sql.go

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/provisionerjobs.sql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,12 @@ SELECT
100100
fj.created_at,
101101
sqlc.embed(pj),
102102
fj.queue_position,
103-
fj.queue_size,
104-
COALESCE(pd.name, '') AS worker_name
103+
fj.queue_size
105104
FROM
106105
final_jobs fj
107106
INNER JOIN provisioner_jobs pj
108107
ON fj.id = pj.id -- Ensure we retrieve full details from `provisioner_jobs`.
109108
-- JOIN with pj is required for sqlc.embed(pj) to compile successfully.
110-
LEFT JOIN provisioner_daemons pd -- Join to get the daemon name corresponding to the job's worker_id
111-
ON pj.worker_id = pd.id
112109
ORDER BY
113110
fj.created_at;
114111

coderd/provisionerjobs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ func convertProvisionerJob(pj database.GetProvisionerJobsByIDsWithQueuePositionR
354354
provisionerJob := pj.ProvisionerJob
355355
job := codersdk.ProvisionerJob{
356356
ID: provisionerJob.ID,
357-
WorkerName: pj.WorkerName,
358357
OrganizationID: provisionerJob.OrganizationID,
359358
CreatedAt: provisionerJob.CreatedAt,
360359
Type: codersdk.ProvisionerJobType(provisionerJob.Type),
@@ -393,10 +392,10 @@ func convertProvisionerJob(pj database.GetProvisionerJobsByIDsWithQueuePositionR
393392
func convertProvisionerJobWithQueuePosition(pj database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerRow) codersdk.ProvisionerJob {
394393
job := convertProvisionerJob(database.GetProvisionerJobsByIDsWithQueuePositionRow{
395394
ProvisionerJob: pj.ProvisionerJob,
396-
WorkerName: pj.WorkerName,
397395
QueuePosition: pj.QueuePosition,
398396
QueueSize: pj.QueueSize,
399397
})
398+
job.WorkerName = pj.WorkerName
400399
job.AvailableWorkers = pj.AvailableWorkers
401400
job.Metadata = codersdk.ProvisionerJobMetadata{
402401
TemplateVersionName: pj.TemplateVersionName,

0 commit comments

Comments
 (0)