Skip to content

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
@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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy