Skip to content

feat: add provisioner daemon name to provisioner jobs responses #17877

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 19, 2025

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented May 16, 2025

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, 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:
Screenshot 2025-05-16 at 11 51 33

Fixes: #16982

@ssncferreira ssncferreira changed the title feat(coderd): add provisioner daemon name to provisioner jobs responses feat: add provisioner daemon name to provisioner jobs responses May 16, 2025
@ssncferreira ssncferreira force-pushed the ssncferreira/feat-add-provisioner-daemon-name branch from 8bb4c7f to 5fc39a0 Compare May 16, 2025 10:39
@ssncferreira ssncferreira marked this pull request as ready for review May 16, 2025 11:00
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're also missing some changes to cliui.ProvisionerJob and friends. If I'm understanding correctly, the provisioner name will now be available in these responses and therefore can be shown in the CLI after the "Queued" message.

EDIT: if we're just keeping the scope to showing the name in the provisioner jobs page, you can disregard what I said above.

@BrunoQuaresma
Copy link
Collaborator

BrunoQuaresma commented May 18, 2025

Related to the design, and the UI, we want to remove the ID and just use the name as @ssncferreira posted on the description screenshot. No need to keep using the ID. If at some point, we have customers asking for the ID, we can think on adding it.

@johnstcn
Copy link
Member

Related to the design, and the UI, we want to remove the ID and just use the name as @ssncferreira posted on the description screenshot. No need to keep using the ID. If at some point, we have customers asking for the ID, we can think on adding it.

Why do we want to remove the ID? Keeping it on the page allows you to Ctrl+F quickly if you already know an ID.

@BrunoQuaresma
Copy link
Collaborator

@johnstcn what is the use case where the user will know the ID and not the name? Eg. We don't show the workspace name because it is more likely to the user know the name than the ID.

We had this conversation with Steven and Kayla, and the thing was, users were debugging using the name and not IDs.

@johnstcn
Copy link
Member

@johnstcn what is the use case where the user will know the ID and not the name? Eg. We don't show the workspace name because it is more likely to the user know the name than the ID.

We had this conversation with Steven and Kayla, and the thing was, users were debugging using the name and not IDs.

My thought was that an admin would have an ID copied from a log or error message. If your research shows that users debug using name and not ID, then you have better data than I do!

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small suggestions, but otherwise LGTM! Nice work!

@@ -120,7 +120,7 @@ export const JobRow: FC<JobRowProps> = ({ job, defaultIsOpen = false }) => {
<>
<dt>Completed by provisioner:</dt>
<dd className="flex items-center gap-2">
<span>{job.worker_id}</span>
<span>{job.worker_name}</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worker name could be empty here if the job is old enough and the provisioner daemon has been cleaned from the DB. We could have some kind of fallback like [removed].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I’ll update it to include a fallback. That said, this raises a question, we still show the “View provisioner” button, which links to the provisioner daemon’s page. If the daemon has been cleaned from the DB, we should avoid showing the button, correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, good catch. Definitely hide/disable the button as well 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled in commit: caed396
@BrunoQuaresma let me know if this change is ok 🙂

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the issues @mafredri highlighted are resolved!

@ssncferreira ssncferreira merged commit f044cc3 into main May 19, 2025
37 of 39 checks passed
@ssncferreira ssncferreira deleted the ssncferreira/feat-add-provisioner-daemon-name branch May 19, 2025 15:05
@github-actions github-actions bot locked and limited conversation to collaborators May 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add provisioner name in the provisioner job response
4 participants