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

Commitf044cc3

Browse files
authored
feat: add provisioner daemon name to provisioner jobs responses (#17877)
# DescriptionThis 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 theprovisioner job API response, was modified to include the new field.**Notes:** * As mentioned in[comment](#17877 (comment)),the `GetProvisionerJobsByIDsWithQueuePosition` query was not changed dueto load concerns. This means that for template and template versionendpoints, `worker_id` will still be returned, but `worker_name` willnot.* Similar to `worker_id`, the `worker_name` is only present once a jobis assigned to a provisioner daemon. For jobs in a pending state (notyet 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` arereturned once a provisioner job reaches the **succeeded** state.- Existing tests covering state transitions and other logic remainunchanged, as they test different scenarios.---# Front-end ChangesAdmin 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:#16982
1 parent87dc247 commitf044cc3

22 files changed

+346
-177
lines changed

‎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-daemon",
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-daemon",
3739
"file_id": "=====[workspace build file ID]======",
3840
"tags": {
3941
"owner": "",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
CREATED AT LAST SEEN AT KEY NAME NAME VERSION STATUS TAGS
2-
====[timestamp]===== ====[timestamp]===== built-in test v0.0.0-devel idle map[owner: scope:organization]
1+
CREATED AT LAST SEEN AT KEY NAME NAMEVERSION STATUS TAGS
2+
====[timestamp]===== ====[timestamp]===== built-in test-daemon v0.0.0-devel idle map[owner: scope:organization]

‎cli/testdata/coder_provisioner_list_--output_json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"key_id": "00000000-0000-0000-0000-000000000001",
66
"created_at": "====[timestamp]=====",
77
"last_seen_at": "====[timestamp]=====",
8-
"name": "test",
8+
"name": "test-daemon",
99
"version": "v0.0.0-devel",
1010
"api_version": "1.6",
1111
"provisioners": [

‎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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ import (
9696
"github.com/coder/coder/v2/testutil"
9797
)
9898

99+
constdefaultTestDaemonName="test-daemon"
100+
99101
typeOptionsstruct {
100102
// AccessURL denotes a custom access URL. By default we use the httptest
101103
// server's URL. Setting this may result in unexpected behavior (especially
@@ -602,7 +604,7 @@ func NewWithAPI(t testing.TB, options *Options) (*codersdk.Client, io.Closer, *c
602604
setHandler(rootHandler)
603605
varprovisionerCloser io.Closer=nopcloser{}
604606
ifoptions.IncludeProvisionerDaemon {
605-
provisionerCloser=NewTaggedProvisionerDaemon(t,coderAPI,"test",options.ProvisionerDaemonTags,coderd.MemoryProvisionerWithVersionOverride(options.ProvisionerDaemonVersion))
607+
provisionerCloser=NewTaggedProvisionerDaemon(t,coderAPI,defaultTestDaemonName,options.ProvisionerDaemonTags,coderd.MemoryProvisionerWithVersionOverride(options.ProvisionerDaemonVersion))
606608
}
607609
client:=codersdk.New(serverURL)
608610
t.Cleanup(func() {
@@ -646,7 +648,7 @@ func (c *ProvisionerdCloser) Close() error {
646648
// well with coderd testing. It registers the "echo" provisioner for
647649
// quick testing.
648650
funcNewProvisionerDaemon(t testing.TB,coderAPI*coderd.API) io.Closer {
649-
returnNewTaggedProvisionerDaemon(t,coderAPI,"test",nil)
651+
returnNewTaggedProvisionerDaemon(t,coderAPI,defaultTestDaemonName,nil)
650652
}
651653

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

‎coderd/database/dbmem/dbmem.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4848,6 +4848,13 @@ func (q *FakeQuerier) GetProvisionerJobsByOrganizationAndStatusWithQueuePosition
48484848
row.AvailableWorkers=append(row.AvailableWorkers,worker.ID)
48494849
}
48504850
}
4851+
4852+
// Add daemon name to provisioner job
4853+
for_,daemon:=rangeq.provisionerDaemons {
4854+
ifjob.WorkerID.Valid&&job.WorkerID.UUID==daemon.ID {
4855+
row.WorkerName=daemon.Name
4856+
}
4857+
}
48514858
rows=append(rows,row)
48524859
}
48534860

‎coderd/database/queries.sql.go

Lines changed: 10 additions & 2 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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ SELECT
160160
COALESCE(t.display_name,'')AS template_display_name,
161161
COALESCE(t.icon,'')AS template_icon,
162162
w.idAS workspace_id,
163-
COALESCE(w.name,'')AS workspace_name
163+
COALESCE(w.name,'')AS workspace_name,
164+
-- Include the name of the provisioner_daemon associated to the job
165+
COALESCE(pd.name,'')AS worker_name
164166
FROM
165167
provisioner_jobs pj
166168
LEFT JOIN
@@ -185,6 +187,9 @@ LEFT JOIN
185187
t.id=tv.template_id
186188
ANDt.organization_id=pj.organization_id
187189
)
190+
LEFT JOIN
191+
-- Join to get the daemon name corresponding to the job's worker_id
192+
provisioner_daemons pdONpd.id=pj.worker_id
188193
WHERE
189194
pj.organization_id= @organization_id::uuid
190195
AND (COALESCE(array_length(@ids::uuid[],1),0)=0ORpj.id= ANY(@ids::uuid[]))
@@ -200,7 +205,8 @@ GROUP BY
200205
t.display_name,
201206
t.icon,
202207
w.id,
203-
w.name
208+
w.name,
209+
pd.name
204210
ORDER BY
205211
pj.created_atDESC
206212
LIMIT

‎coderd/provisionerjobs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ func convertProvisionerJobWithQueuePosition(pj database.GetProvisionerJobsByOrga
395395
QueuePosition:pj.QueuePosition,
396396
QueueSize:pj.QueueSize,
397397
})
398+
job.WorkerName=pj.WorkerName
398399
job.AvailableWorkers=pj.AvailableWorkers
399400
job.Metadata= codersdk.ProvisionerJobMetadata{
400401
TemplateVersionName:pj.TemplateVersionName,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp