Skip to content

feat: add queue_position and queue_size to provisioner jobs #8074

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 4 commits into from
Jun 20, 2023

Conversation

kylecarbs
Copy link
Member

This should help with monitoring for large-scale deployments.

We can add an indicator to the UI for the queue position of workspaces!

This should help with monitoring for large-scale deployments.

We can add an indicator to the UI for the queue position of workspaces!
@kylecarbs kylecarbs requested review from coadler and bpmct June 17, 2023 04:16
@kylecarbs kylecarbs self-assigned this Jun 17, 2023
@bpmct
Copy link
Member

bpmct commented Jun 18, 2023

Does this take into account tagged provisioners and jobs? Two examples come to mind:

Case 1) A user starts a build that requires provisioners with a specific tag (environment: on-prem). There is a queue of 100 builds and 20 provisioners, but only 5 provisioners apply for environment: on-prem`.

Case 2) A user starts a build that requires provisioners with a specific tag (`environment: on-prem). There is a queue of 100 builds and 20 provisioners, but all on-prem provisioners are offline.

I don't think either of these needs to be addressed now, we have an internal RFC that outlines some of these problems. I was mostly curious. There is also no way for a tagged provisioner to reject jobs (#6442), which is also mentioned there.

FWIW, I don't think it's a bad UX for "position in queue" to ignore tags, as long as we have to surface some error when no provisions are available with a given tag. For example, when you are looking at your spot in line on a restaurant's app, it is common for that queue position to be a "worse case" and for you to quickly jump spots in line based on your party size, etc.

@kylecarbs
Copy link
Member Author

@bpmct it doesn't in the present form, but can with extreme ease (we just join based on tags).

We can improve this in the future once the tagging system and list of provisioners becomes visible in the UI.

@mtojek mtojek requested a review from rodrimaia June 20, 2023 15:59
job, err := api.Database.GetProvisionerJobByID(ctx, templateVersion.JobID)
if err != nil {
jobs, err := api.Database.GetProvisionerJobsByIDsWithQueuePosition(ctx, []uuid.UUID{templateVersion.JobID})
if err != nil || len(jobs) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I really like needing to shoehorn this new function to fulfil both of the old queries. Do we really need to return the queue position in all of these routes? What if the frontend only fetched them when it knows it's waiting on a build?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the schema should stay consistent rather than occasionally being there. Unless we observe a performance problem of course.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove the old queries then? Would be nice to have a :one and :many query as well so you don't have to || len(jobs) == 0 all the time. That seems like a pretty easy footgun

Copy link
Member Author

Choose a reason for hiding this comment

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

I did that initially, but figured that was a mistake because we frequently query just to collect perms, where it's a complete waste to get the queue pos.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

bump

Would be nice to have a :one and :many query as well so you don't have to || len(jobs) == 0 all the time. That seems like a pretty easy footgun

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, I think the opposite, actually. Because the query itself has many joins and such, I think it'd be a mistake to duplicate that.

Copy link
Contributor

Choose a reason for hiding this comment

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

sad that sqlc doesn't have better templating for this

Co-authored-by: Colin Adler <colin1adler@gmail.com>
@kylecarbs kylecarbs merged commit 69f911d into main Jun 20, 2023
@kylecarbs kylecarbs deleted the queueposition branch June 20, 2023 20:07
@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2023
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.

3 participants