Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8bb4c7f

Browse files
committed
feat(coderd): add provisioner daemon name to provisioner jobs responses
1 parentcf98268 commit8bb4c7f

22 files changed

+622
-168
lines changed

‎cli/testdata/coder_list_--output_json.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"completed_at": "====[timestamp]=====",
3838
"status": "succeeded",
3939
"worker_id": "====[workspace build worker ID]=====",
40+
"worker_name": "test",
4041
"file_id": "=====[workspace build file ID]======",
4142
"tags": {
4243
"owner": "",

‎cli/testdata/coder_provisioner_jobs_list_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OPTIONS:
1111
-O, --org string, $CODER_ORGANIZATION
1212
Select which organization (uuid or name) to use.
1313

14-
-c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,type,template display name,status,queue,tags)
14+
-c, --column [id|created at|started at|completed at|canceled at|error|error code|status|worker id|worker name|file id|tags|queue position|queue size|organization id|template version id|workspace build id|type|available workers|template version name|template id|template name|template display name|template icon|workspace id|workspace name|organization|queue] (default: created at,id,type,template display name,status,queue,tags)
1515
Columns to display in table output.
1616

1717
-l, --limit int, $CODER_PROVISIONER_JOB_LIST_LIMIT (default: 50)

‎cli/testdata/coder_provisioner_jobs_list_--output_json.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"completed_at": "====[timestamp]=====",
77
"status": "succeeded",
88
"worker_id": "====[workspace build worker ID]=====",
9+
"worker_name": "test",
910
"file_id": "=====[workspace build file ID]======",
1011
"tags": {
1112
"owner": "",
@@ -34,6 +35,7 @@
3435
"completed_at": "====[timestamp]=====",
3536
"status": "succeeded",
3637
"worker_id": "====[workspace build worker ID]=====",
38+
"worker_name": "test",
3739
"file_id": "=====[workspace build file ID]======",
3840
"tags": {
3941
"owner": "",

‎coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func (c *ProvisionerdCloser) Close() error {
645645
// well with coderd testing. It registers the "echo" provisioner for
646646
// quick testing.
647647
funcNewProvisionerDaemon(t testing.TB,coderAPI*coderd.API) io.Closer {
648-
returnNewTaggedProvisionerDaemon(t,coderAPI,"test",nil)
648+
returnNewTaggedProvisionerDaemon(t,coderAPI,"test-daemon",nil)
649649
}
650650

651651
funcNewTaggedProvisionerDaemon(t testing.TB,coderAPI*coderd.API,namestring,provisionerTagsmap[string]string) io.Closer {

‎coderd/database/dbmem/dbmem.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,14 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedTagBasedQueu
12671267
// Step 6: Compute the final results with minimal checks
12681268
varresults []database.GetProvisionerJobsByIDsWithQueuePositionRow
12691269
for_,job:=rangefilteredJobs {
1270+
workerName:=""
1271+
// Add daemon name to provisioner job
1272+
for_,daemon:=rangeq.provisionerDaemons {
1273+
ifjob.WorkerID.Valid&&job.WorkerID.UUID==daemon.ID {
1274+
workerName=daemon.Name
1275+
}
1276+
}
1277+
12701278
// If the job has a computed rank, use it
12711279
ifrank,found:=jobQueueStats[job.ID];found {
12721280
results=append(results,rank)
@@ -1278,6 +1286,7 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedTagBasedQueu
12781286
ProvisionerJob:job,
12791287
QueuePosition:0,
12801288
QueueSize:0,
1289+
WorkerName:workerName,
12811290
})
12821291
}
12831292
}
@@ -4848,6 +4857,13 @@ func (q *FakeQuerier) GetProvisionerJobsByOrganizationAndStatusWithQueuePosition
48484857
row.AvailableWorkers=append(row.AvailableWorkers,worker.ID)
48494858
}
48504859
}
4860+
4861+
// Add daemon name to provisioner job
4862+
for_,daemon:=rangeq.provisionerDaemons {
4863+
ifjob.WorkerID.Valid&&job.WorkerID.UUID==daemon.ID {
4864+
row.WorkerName=daemon.Name
4865+
}
4866+
}
48514867
rows=append(rows,row)
48524868
}
48534869

‎coderd/database/queries.sql.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/provisionerjobs.sql

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ SELECT
100100
fj.created_at,
101101
sqlc.embed(pj),
102102
fj.queue_position,
103-
fj.queue_size
103+
fj.queue_size,
104+
COALESCE(pd.name,'')AS worker_name
104105
FROM
105106
final_jobs fj
106107
INNER JOIN provisioner_jobs pj
107108
ONfj.id=pj.id-- Ensure we retrieve full details from `provisioner_jobs`.
108109
-- 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+
ONpj.worker_id=pd.id
109112
ORDER BY
110113
fj.created_at;
111114

@@ -160,7 +163,9 @@ SELECT
160163
COALESCE(t.display_name,'')AS template_display_name,
161164
COALESCE(t.icon,'')AS template_icon,
162165
w.idAS workspace_id,
163-
COALESCE(w.name,'')AS workspace_name
166+
COALESCE(w.name,'')AS workspace_name,
167+
-- Include the name of the provisioner_daemon associated to the job
168+
COALESCE(pd.name,'')AS worker_name
164169
FROM
165170
provisioner_jobs pj
166171
LEFT JOIN
@@ -185,6 +190,9 @@ LEFT JOIN
185190
t.id=tv.template_id
186191
ANDt.organization_id=pj.organization_id
187192
)
193+
LEFT JOIN
194+
-- Join to get the daemon name corresponding to the job's worker_id
195+
provisioner_daemons pdONpd.id=pj.worker_id
188196
WHERE
189197
pj.organization_id= @organization_id::uuid
190198
AND (COALESCE(array_length(@ids::uuid[],1),0)=0ORpj.id= ANY(@ids::uuid[]))
@@ -200,7 +208,8 @@ GROUP BY
200208
t.display_name,
201209
t.icon,
202210
w.id,
203-
w.name
211+
w.name,
212+
pd.name
204213
ORDER BY
205214
pj.created_atDESC
206215
LIMIT

‎coderd/provisionerjobs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ func convertProvisionerJob(pj database.GetProvisionerJobsByIDsWithQueuePositionR
354354
provisionerJob:=pj.ProvisionerJob
355355
job:= codersdk.ProvisionerJob{
356356
ID:provisionerJob.ID,
357+
WorkerName:pj.WorkerName,
357358
OrganizationID:provisionerJob.OrganizationID,
358359
CreatedAt:provisionerJob.CreatedAt,
359360
Type:codersdk.ProvisionerJobType(provisionerJob.Type),
@@ -392,6 +393,7 @@ func convertProvisionerJob(pj database.GetProvisionerJobsByIDsWithQueuePositionR
392393
funcconvertProvisionerJobWithQueuePosition(pj database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerRow) codersdk.ProvisionerJob {
393394
job:=convertProvisionerJob(database.GetProvisionerJobsByIDsWithQueuePositionRow{
394395
ProvisionerJob:pj.ProvisionerJob,
396+
WorkerName:pj.WorkerName,
395397
QueuePosition:pj.QueuePosition,
396398
QueueSize:pj.QueueSize,
397399
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp