- Notifications
You must be signed in to change notification settings - Fork927
feat(coderd): add filters and fix template for provisioner daemons#16558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -45,9 +45,12 @@ SELECT | ||
current_job.job_status AS current_job_status, | ||
previous_job.id AS previous_job_id, | ||
previous_job.job_status AS previous_job_status, | ||
COALESCE(current_template.name, ''::text) AS current_job_template_name, | ||
COALESCE(current_template.display_name, ''::text) AS current_job_template_display_name, | ||
COALESCE(current_template.icon, ''::text) AS current_job_template_icon, | ||
COALESCE(previous_template.name, ''::text) AS previous_job_template_name, | ||
COALESCE(previous_template.display_name, ''::text) AS previous_job_template_display_name, | ||
COALESCE(previous_template.icon, ''::text) AS previous_job_template_icon | ||
FROM | ||
provisioner_daemons pd | ||
JOIN | ||
@@ -72,16 +75,30 @@ LEFT JOIN | ||
LIMIT 1 | ||
) | ||
) | ||
-- Current job information. | ||
LEFT JOIN | ||
workspace_builds current_build ONcurrent_build.id =CASE WHEN current_job.input ? 'workspace_build_id' THEN(current_job.input->>'workspace_build_id')::uuid END | ||
LEFT JOIN | ||
-- We should always have a template version, either explicitly or implicitly via workspace build. | ||
template_versions current_version ON current_version.id = CASE WHEN current_job.input ? 'template_version_id' THEN (current_job.input->>'template_version_id')::uuid ELSE current_build.template_version_id END | ||
LEFT JOIN | ||
templates current_template ON current_template.id = current_version.template_id | ||
-- Previous job information. | ||
LEFT JOIN | ||
workspace_builds previous_build ON previous_build.id = CASE WHEN previous_job.input ? 'workspace_build_id' THEN (previous_job.input->>'workspace_build_id')::uuid END | ||
LEFT JOIN | ||
-- We should always have a template version, either explicitly or implicitly via workspace build. | ||
template_versions previous_version ON previous_version.id = CASE WHEN previous_job.input ? 'template_version_id' THEN (previous_job.input->>'template_version_id')::uuid ELSE previous_build.template_version_id END | ||
LEFT JOIN | ||
templates previous_template ON previous_template.id = previous_version.template_id | ||
Comment on lines +78 to +93 MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Review: I completed this because it was missing some things. But I wonder if we need to take RBAC into consideration now? The endpoint previously returned a job ID/status only, now it also returns information regarding the template that job is associated with. This has some implications considering regular members are allowed to view provisioner daemon resources. WDYT@johnstcn? I'm not particularly fond of it, but we could add the same authorization to the API endpoint as for jobs: // For now, only owners and template admins can access provisioner jobs.if!api.Authorize(r,policy.ActionRead,rbac.ResourceProvisionerJobs.InOrg(org.ID)) {httpapi.ResourceNotFound(rw)returnnil,false} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't know how sensitive I think some further questions we need to answer before we can even update the RBAC rules are:
To be safe, I think we should promote the same level of access control as for provisioner jobsfor now. We should add a follow-up issue to take provisioner job ownership and template-level ACLs into account. Does that sound reasonable to you? | ||
WHERE | ||
pd.organization_id = @organization_id::uuid | ||
AND (COALESCE(array_length(@ids::uuid[], 1), 0) = 0 OR pd.id = ANY(@ids::uuid[])) | ||
AND (@tags::tagset = 'null'::tagset OR provisioner_tagset_contains(pd.tags::tagset, @tags::tagset)) | ||
ORDER BY | ||
pd.created_at ASC | ||
LIMIT | ||
sqlc.narg('limit')::int; | ||
-- name: DeleteOldProvisionerDaemons :exec | ||
-- Delete provisioner daemons that have been created at least a week ago | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.