Skip to content

[ws-manager-mk2] Workspace timeouts #16209

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 1 commit into from
Feb 10, 2023
Merged

[ws-manager-mk2] Workspace timeouts #16209

merged 1 commit into from
Feb 10, 2023

Conversation

WVerlaek
Copy link
Member

@WVerlaek WVerlaek commented Feb 3, 2023

Description

Implements workspace timeouts.

Depends on #16181 to mark user activity.

Differences with mk1:

  • Check for timeouts using a controller instead of a loop running on a timer:
    • Use a (new) controller to monitor workspaces and add the Timeout condition, instead of a timer running every 15 seconds checking all workspaces in a separate goroutine.
      • The new timeout_controller requeues reconcile events, such that each workspace gets reconciled every 15 seconds.
      • It's implemented as a separate controller than the workspace_controller, to keep the reconcile loop light-weight, as it runs every 15 seconds for each workspace. Both controllers share the same k8s cache provided by the controller manager.
  • Handling pod restarts for in-memory cache of workspace's last user activity:
    • Instead of marking all workspaces as Active on ws-manager restarting (to prevent the workspaces from timing out immediately after a restart), keep track of the controller startup time to check for a given workspace if a restart occurred.
    • If a restart happened, handle timeouts differently, by "resetting" the timeout to the time of the restart. See comments in code in the WorkspacePhaseRunning phase for more details.

See https://github.com/gitpod-io/gitpod/blob/main/components/ws-manager/pkg/manager/status.go#L747 to compare against mk1 timeout logic.

Related Issue(s)

Relates to #11416

How to test

Check regular workspace timeout:

  • Create a workspace
  • Edit the workspace CR and set spec.Timeout to 1m
  • Wait 1m
  • Observe workspace closes due to a timeout

Check restarting ws-manager-mk2 doesn't close workspaces due to in-memory map of last workspace activity clearing on restart:

  • Create a workspace
  • Edit the workspace CR and set spec.Timeout to 1m
  • Keep the workspace active for >2 minutes (also keep it active during the below steps)
  • After 2 minutes, restart ws-manager-mk2
  • Check that ws-manager-mk2 doesn't timeout the workspace on restart (due to no longer having a last user activity timestamp for the workspace)

Release Notes

NONE

Documentation

Build Options:

  • /werft with-github-actions
    Experimental feature to run the build with GitHub Actions (and not in Werft).
  • leeway-no-cache
    leeway-target=components:all
  • /werft no-test
    Run Leeway with --dont-test
  • /werft publish-to-npm

Preview Environment Options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft with-wsman-mk2
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-wv-mk2-timeout-ctrl.1 because the annotations in the pull request description changed
(with .werft/ from main)

@github-actions github-actions bot added the team: workspace Issue belongs to the Workspace team label Feb 3, 2023
@WVerlaek
Copy link
Member Author

WVerlaek commented Feb 6, 2023

/werft run

👍 started the job as gitpod-build-wv-mk2-timeout-ctrl.2
(with .werft/ from main)

@WVerlaek WVerlaek force-pushed the wv/mk2-timeout-ctrl branch from 3078c8c to bc5bb99 Compare February 7, 2023 09:49
Base automatically changed from wv/mk2-mark-active to main February 7, 2023 09:51
@WVerlaek WVerlaek force-pushed the wv/mk2-timeout-ctrl branch from bc5bb99 to 580ff08 Compare February 7, 2023 10:07
@WVerlaek
Copy link
Member Author

WVerlaek commented Feb 7, 2023

/werft run recreate-vm

👍 started the job as gitpod-build-wv-mk2-timeout-ctrl.5
(with .werft/ from main)

@WVerlaek WVerlaek force-pushed the wv/mk2-timeout-ctrl branch 2 times, most recently from 679f346 to c360b94 Compare February 9, 2023 16:13
@WVerlaek WVerlaek force-pushed the wv/mk2-timeout-ctrl branch from c360b94 to 0c60ae6 Compare February 10, 2023 09:39
@WVerlaek WVerlaek requested a review from Furisto February 10, 2023 09:39
@roboquat roboquat merged commit 172c58c into main Feb 10, 2023
@roboquat roboquat deleted the wv/mk2-timeout-ctrl branch February 10, 2023 09:49
@roboquat roboquat added deployed: workspace Workspace team change is running in production deployed Change is completely running in production labels Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: workspace Workspace team change is running in production deployed Change is completely running in production release-note-none size/XL team: workspace Issue belongs to the Workspace team
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants