File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,12 @@ WITH latest AS (
18
18
-- workspace auto started at the given time and the original
19
19
-- TTL was applied.
20
20
WHEN NOW() + (' 60 minutes' )::interval > @next_autostart :: timestamptz
21
- -- If the autostart is behind the created_at , then the
21
+ -- If the autostart is behind now() , then the
22
22
-- autostart schedule is either the 0 time and not provided,
23
23
-- or it was the autostart in the past, which is no longer
24
24
-- relevant. If a past autostart is being passed in,
25
25
-- that is a mistake by the caller.
26
- AND @next_autostart > workspace_builds . created_at
26
+ AND @next_autostart > NOW()
27
27
THEN
28
28
-- Extend to the autostart, then add the TTL
29
29
((@next_autostart :: timestamptz ) - NOW()) + CASE
54
54
updated_at = NOW(),
55
55
deadline = CASE
56
56
WHEN l .build_max_deadline = ' 0001-01-01 00:00:00+00'
57
- THEN NOW() + l .ttl_interval
58
- ELSE LEAST(NOW() + l .ttl_interval , l .build_max_deadline )
57
+ -- Never reduce the deadline from activity.
58
+ THEN GREATEST(wb .deadline , NOW() + l .ttl_interval )
59
+ ELSE LEAST(GREATEST(wb .deadline , NOW() + l .ttl_interval ), l .build_max_deadline )
59
60
END
60
61
FROM latest l
61
62
WHERE wb .id = l .build_id
You can’t perform that action at this time.
0 commit comments