Skip to content

feat: autostop workspaces owned by suspended users #13790

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 7 commits into from
Jul 4, 2024
Merged

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Jul 4, 2024

Fixed: #8051

This PR modifies autostop rules to stop workspaces owned by suspended users.

@mtojek mtojek self-assigned this Jul 4, 2024
@mtojek mtojek marked this pull request as ready for review July 4, 2024 12:41
@mtojek mtojek requested review from johnstcn and dannykopping July 4, 2024 12:41
@@ -387,6 +387,10 @@ func isEligibleForAutostop(ws database.Workspace, build database.WorkspaceBuild,
return false
}

if build.Transition == database.WorkspaceTransitionStart && user.Status == database.UserStatusSuspended {
Copy link
Member

Choose a reason for hiding this comment

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

Do we care about any other user statuses?

Copy link
Member Author

@mtojek mtojek Jul 4, 2024

Choose a reason for hiding this comment

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

No, I don't want to mess with others - just suspended.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to mention dormant but figured it was out of scope; should dormant users be allowed to run workloads?

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC on the first interaction with API the dormant user will be switched to active, so yes.

Copy link
Member

@johnstcn johnstcn Jul 4, 2024

Choose a reason for hiding this comment

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

By definition... they shouldn't be able to...? Once they log in, they're active.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, what is your preference - should I extend the logic to dormant users too?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it could be a follow-up PR since there may be additional considerations.

Comment on lines 596 to 600
// When: the autobuild executor ticks after the scheduled time
go func() {
tickCh <- sched.Next(workspace.LatestBuild.CreatedAt)
close(tickCh)
}()
Copy link
Member

Choose a reason for hiding this comment

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

Do we want the executor to immediately stop workspaces of suspended users, or wait until the workspace has its time to shut down? This is testing the latter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume that the lifecycle executor stops the workspace right after the conditional logic is satisfied? Do you have a specific idea in mind on how we can improve testing?

Copy link
Member

Choose a reason for hiding this comment

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

No matter what time you send down the channel, it should result in the workspace being stopped.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for more context. I excluded sched from the test.

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM

@mtojek mtojek enabled auto-merge (squash) July 4, 2024 13:28
@mtojek mtojek merged commit 7c41f95 into main Jul 4, 2024
28 checks passed
@mtojek mtojek deleted the 8051-stop-workspace branch July 4, 2024 13:35
@github-actions github-actions bot locked and limited conversation to collaborators Jul 4, 2024
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.

Stop a user's workspaces when their account is suspended
3 participants