Skip to content

[ws-manager-mk2] Support workspace snapshots #16471

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 9 commits into from
Feb 23, 2023
Merged

[ws-manager-mk2] Support workspace snapshots #16471

merged 9 commits into from
Feb 23, 2023

Conversation

Furisto
Copy link
Member

@Furisto Furisto commented Feb 19, 2023

Description

Adds support for snapshotting workspaces

Related Issue(s)

n.a.

How to test

  • Make sure the node is labeled, kubectl label node fo-mk2-snapshots gitpod.io/experimental=true
  • Open workspace in preview environment
  • Select "Share workspace snapshot" option and take snapshot
  • After a while a snapshot should have been created

Release Notes

None

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
Publish Options
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer Options
  • with-ee-license
  • with-slow-database
  • with-dedicated-emulation
  • with-ws-manager-mk2
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated

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-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@Furisto
Copy link
Member Author

Furisto commented Feb 20, 2023

/werft run with-preview with-large-vm with-wsman-mk2

👍 started the job as gitpod-build-fo-mk2-snapshots.26
(with .werft/ from main)

@kylos101
Copy link
Contributor

kylos101 commented Feb 23, 2023

/werft run with-preview with-large-vm with-wsman-mk2

👍 started the job as gitpod-build-fo-mk2-snapshots.27
(with .werft/ from main)

Verbs: []string{
"get",
"patch",
"update",
Copy link
Contributor

@kylos101 kylos101 Feb 23, 2023

Choose a reason for hiding this comment

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

Question: Do ws-manager-mk2 and ws-daemon both need patch and update for snapshots/status? I thought we were trying to consolidate update verbs to single sources of truth.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated scope of permissions

@kylos101
Copy link
Contributor

@Furisto can you update with components/ws-daemon/pkg/controller/controller.go conflicted file?

Copy link
Member

@WVerlaek WVerlaek left a comment

Choose a reason for hiding this comment

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

some comments but LGTM otherwise. I like the use of the Snapshot resource

// SetupWithManager sets up the controller with the Manager.
func (r *SnapshotReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&workspacev1.Snapshot{}).
Copy link
Member

Choose a reason for hiding this comment

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

changed this recently for the other controllers, lets explicitly name each controller, as the name shows up in the metrics and allows us to differentiate different controllers for the same resource. (By default the controller name is the name of the resource it owns)

Suggested change
For(&workspacev1.Snapshot{}).
Named("snapshot").
For(&workspacev1.Snapshot{}).

log.Error(err, "could not set completion status for snapshot", "workspace", snapshot.Spec.WorkspaceID)
}

return ctrl.Result{}, err
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 delete the Snapshot resource somewhere after some time?

Might make sense to set a completion timestamp, and then clean up any snapshots completed e.g. > 30 mins ago?

Copy link
Member Author

Choose a reason for hiding this comment

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

The owner of the snapshot is the workspace so the snapshot gets deleted when the workspace gets deleted (cascading delete) which I think is pretty nice. We can inspect the snapshots taken by a workspace while it is running and we ensure that the snapshot CR does not outlive the workspace so that we do not try to take a snapshot from a stopped workspace.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@WVerlaek
Copy link
Member

Tested and the following worked nicely in a preview env:

  • Open workspace
  • Modify a file
  • Take snapshot with gp snapshot
  • Open workspace from snapshot
  • Check file modifications are there in workspace opened from snapshot

As an aside found some small error logging issues in content-service while checking the daemon logs: #16527

- Name controller
- Return early in case of error
- Reduce scope of permissions
Copy link
Contributor

@kylos101 kylos101 left a comment

Choose a reason for hiding this comment

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

✔️

@roboquat roboquat merged commit 116a5b9 into main Feb 23, 2023
@roboquat roboquat deleted the fo/mk2-snapshots branch February 23, 2023 15:45
@roboquat roboquat added the deployed: workspace Workspace team change is running in production label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: In Validation
Development

Successfully merging this pull request may close these issues.

5 participants