-
Notifications
You must be signed in to change notification settings - Fork 936
feat!: bump workspace activity by 1 hour #10704
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
Changes from 1 commit
7bd2123
141cba9
c36b27d
b8f88a7
dc84fb8
f088523
566dd38
696d925
f4d6c59
a8327f0
69c6d8a
32175d8
05e11c4
3f1327b
ceb3bd8
4d04500
8e3ed21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Will bump by ttl if crosses an autostart threshold
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,29 @@ WITH latest AS ( | |
provisioner_jobs.completed_at::timestamp with time zone AS job_completed_at, | ||
( | ||
CASE | ||
WHEN templates.allow_user_autostop | ||
THEN (workspaces.ttl / 1000 / 1000 / 1000 || ' seconds')::interval | ||
ELSE (templates.default_ttl / 1000 / 1000 / 1000 || ' seconds')::interval | ||
-- If the extension would push us over the next_autostart | ||
-- interval, then extend the deadline by the full ttl from | ||
-- the autostart time. This will essentially be as if the | ||
-- workspace auto started at the given time and the original | ||
-- TTL was applied. | ||
WHEN NOW() + ('60 minutes')::interval > @next_autostart :: timestamptz | ||
-- If the autostart is behind the created_at, then the | ||
-- autostart schedule is either the 0 time and not provided, | ||
-- or it was the autostart in the past, which is no longer | ||
-- relevant. If a past autostart is being passed in, | ||
-- that is a mistake by the caller. | ||
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: not necessarily, this can happen due to a failed get from the template schedule store. 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. Then it would be the zero time. Let me clarify that I mean passing in a timestamp that is in the past, but above the zero time. |
||
AND @next_autostart > workspace_builds.created_at | ||
THEN | ||
-- Extend to the autostart, then add the TTL | ||
((@next_autostart :: timestamptz) - NOW()) + CASE | ||
WHEN templates.allow_user_autostop | ||
THEN (workspaces.ttl / 1000 / 1000 / 1000 || ' seconds')::interval | ||
ELSE (templates.default_ttl / 1000 / 1000 / 1000 || ' seconds')::interval | ||
END | ||
|
||
-- Default to 60 minutes. | ||
ELSE | ||
('60 minutes')::interval | ||
END | ||
) AS ttl_interval | ||
FROM workspace_builds | ||
|
Uh oh!
There was an error while loading. Please reload this page.