Skip to content

fix(coderd): show correct deletion time in dormancy notification - #26488

Merged
zedkipp merged 3 commits into
mainfrom
zedkipp/plat-220-dormancy-notification
Jun 18, 2026
Merged

fix(coderd): show correct deletion time in dormancy notification#26488
zedkipp merged 3 commits into
mainfrom
zedkipp/plat-220-dormancy-notification

Conversation

@zedkipp

@zedkipp zedkipp commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

The dormancy notification's "will be automatically deleted in X" sentence rendered the dormancy threshold instead of the auto-delete duration. A 30-day threshold rendered as "4 weeks" even when auto-delete was 90 days; a 60-day threshold rendered as "1 month" with a 7-day auto-delete. Render the countdown from the auto-delete setting, and skip the deletion sentence entirely when auto-delete is disabled so the notification no longer promises a deletion that will never happen.

@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

PLAT-220

The dormancy notification's "will be automatically deleted in X"
sentence rendered the dormancy threshold instead of the auto-delete
duration. A 30-day threshold rendered as "4 weeks" even when
auto-delete was 90 days; a 60-day threshold rendered as "1 month"
with a 7-day auto-delete. Render the countdown from the auto-delete
setting, and skip the deletion sentence entirely when auto-delete
is disabled so the notification no longer promises a deletion that
will never happen.
@zedkipp
zedkipp force-pushed the zedkipp/plat-220-dormancy-notification branch from 7686a27 to b03984c Compare June 17, 2026 20:55
@zedkipp
zedkipp requested review from Emyrk and jscottmiller June 17, 2026 21:34
@zedkipp
zedkipp marked this pull request as ready for review June 17, 2026 21:34
Comment thread coderd/workspaces.go

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Worth testing the new branch in workspaces_test.go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. I added similar test coverage here.

Comment thread coderd/autobuild/lifecycle_executor.go Outdated
// Auto-delete must be configured for the body to render a
// deletion timeline.
if tmpl.TimeTilDormantAutoDelete > 0 {
deleteTime := dbtime.Now().Add(time.Duration(tmpl.TimeTilDormantAutoDelete))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rather than generating the delete time with now + offset, we could use the updated DeletingAt returned from UpdateWorkspaceDormantDeletingAt via wsNew (mutating ws as we do with DormantAt). In practice this only saves us a very very minor data race between template updates and this loop and a bit of code duplication, so it isn't a big deal.

@zedkipp zedkipp Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good thinking here! This is an even bigger win because it eliminates any race and removes a DB query for the template.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah didn't realize the template was only needed for this - nice!

Eventually it might be nice to tighten up the time handling in our state transitions. As it stands now, a coder instance that's stopped for 30 days with dormant=7day and delete=7days template will have its workspaces immediately set to dormant when it starts back up but the deletion would be queued for now+7 days (at least, I think this is true). This is perhaps surprising (it would be to me), perhaps intentional, and certainly not a big deal. It would be nice if the transitions worked more like a discrete time simulation, where the reference time wasn't time.Now() but the time of the last item in the causal chain. Applying this idea to dormancy, we could pass ws.LastUsedAt (which is used to gate the transition) to UpdateWorkspaceDormantDeletingAt rather than dbtime.Now(). I'm not advocating for this change here btw (it might break other assumptions), it's just that all the Now() calls give me the ick. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Very fair point on all the ad-hoc timestamps. It's a recurring pain point I see in many tests, and a theme in flakes I've fixed over time.

Zach Kipp added 2 commits June 18, 2026 16:05
The dormancy notification previously quoted a deletion deadline derived from a cached template snapshot, separate from the deadline the database had just recorded on the workspace itself. Bind the notification to the workspace's recorded deadline instead.
…ration to 000527

main landed 000526_boundary_log_owner; bump to avoid the collision.
@zedkipp
zedkipp enabled auto-merge (squash) June 18, 2026 20:09
@zedkipp
zedkipp merged commit 76fa1d4 into main Jun 18, 2026
29 checks passed
@zedkipp
zedkipp deleted the zedkipp/plat-220-dormancy-notification branch June 18, 2026 20:17
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
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.

2 participants