-
Notifications
You must be signed in to change notification settings - Fork 886
feat: update workspace deadline when template policy changes #8964
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It all looks fine, just wondering if this is going to become a slow function. Can we instrument it or trace it in some way that if it gets slow we can see it?
if s.UseRestartRequirement.Load() { | ||
err = s.updateWorkspaceBuilds(ctx, db, template) | ||
if err != nil { | ||
return xerrors.Errorf("update workspace builds: %w", err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long can this take if there are a lot of workspaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a few queries for each workspace, multiple selects and then an update. I don't think it will take very long, even with thousands of workspaces this should take less than a few seconds. I'll add instrumentation though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave the approve. Instrumentation would be the only thing I would add 👍
Updates the max deadline for the latest build (if it's the "start" transition) for each workspace using a template when the template changes it's policy.
Recalculate the max deadline using the job's completed_at time as "now" and apply it to the workspace build. If it's before
now() + 2h
then set the max deadline tonow() + 2h
. If the existing deadline exceeds the new max deadline, set it to the max deadline.This only happens when the template policy changes, not when the user changes their quiet hours (to avoid gaming the system, they will need to restart workspaces for the new quiet hours to apply).
Closes #8837