Skip to content

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

Merged
merged 17 commits into from
Nov 15, 2023
Prev Previous commit
Next Next commit
Never reduce the deadline
  • Loading branch information
Emyrk committed Nov 14, 2023
commit 141cba941ba831fc1a6c77c56c7575dd8527ef92
9 changes: 5 additions & 4 deletions coderd/database/queries/activitybump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ WITH latest AS (
-- 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
-- If the autostart is behind now(), 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.
AND @next_autostart > workspace_builds.created_at
AND @next_autostart > NOW()
THEN
-- Extend to the autostart, then add the TTL
((@next_autostart :: timestamptz) - NOW()) + CASE
Expand Down Expand Up @@ -54,8 +54,9 @@ SET
updated_at = NOW(),
deadline = CASE
WHEN l.build_max_deadline = '0001-01-01 00:00:00+00'
THEN NOW() + l.ttl_interval
ELSE LEAST(NOW() + l.ttl_interval, l.build_max_deadline)
-- Never reduce the deadline from activity.
THEN GREATEST(wb.deadline, NOW() + l.ttl_interval)
ELSE LEAST(GREATEST(wb.deadline, NOW() + l.ttl_interval), l.build_max_deadline)
END
FROM latest l
WHERE wb.id = l.build_id
Expand Down