Skip to content

[ws-manager-mk2] Rely on controller concurrency mechanism for content init and backup #16823

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 3 commits into from
Mar 23, 2023

Conversation

Furisto
Copy link
Member

@Furisto Furisto commented Mar 13, 2023

Description

Replaces our own in-memory concurrency mechanism with the concurrency mechanism of the controller runtime. This is the first step towards making ws-daemon restartable but we are not there yet with this PR. Further testing needs to be done to ensure that this works in all cases.

Related Issue(s)

n.a.

How to test

  • Open workspace in workspace preview
  • Everything should work as before

Release Notes

None

Build Options:

  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /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-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

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-fo-mk2-daemon-restart.2 because the annotations in the pull request description changed
(with .werft/ from main)

@Furisto Furisto force-pushed the fo/mk2-daemon-restart branch from c595e4d to 6815f8c Compare March 15, 2023 16:31
@roboquat roboquat added size/XL and removed size/XXL labels Mar 15, 2023
@Furisto Furisto force-pushed the fo/mk2-daemon-restart branch from 1854ad3 to 10bea8a Compare March 20, 2023 16:03
@Furisto Furisto changed the title [ws-manager-mk2] Make ws-daemon restartable [ws-manager-mk2] Rely on controller concurrency mechanism for content init and backup Mar 20, 2023
@Furisto Furisto marked this pull request as ready for review March 20, 2023 16:21
@Furisto Furisto requested a review from a team March 20, 2023 16:21
Comment on lines 126 to 128
if !wsc.latestWorkspace(ctx, &workspace) {
return ctrl.Result{Requeue: true}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

we should only do this at the point we're trying to start a content init or backup, otherwise we'll be sending an update on every reconciliation (which then again requeues a reconciliation, doesn't this result in an endless loop of reconciliations?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Haven't seen it 🤔 but makes a ton of sense.

@@ -140,6 +144,13 @@ func (wsc *WorkspaceController) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, nil
}

func (wsc *WorkspaceController) latestWorkspace(ctx context.Context, ws *workspacev1.Workspace) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some comments on why we need this? For the future reader 😄

@@ -152,7 +163,7 @@ func (wsc *WorkspaceController) handleWorkspaceInit(ctx context.Context, ws *wor
}

Copy link
Member

Choose a reason for hiding this comment

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

i.e. move the latestWorkspace check to here, just before we're attempting to start the content init

@Furisto
Copy link
Member Author

Furisto commented Mar 21, 2023

@WVerlaek PTAL

ws.Status.SetCondition(workspacev1.NewWorkspaceConditionRefresh())

err := wsc.Client.Status().Update(ctx, ws)
return !errors.IsConflict(err)
Copy link
Member

Choose a reason for hiding this comment

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

if there's a different error (e.g. api server temporarily unavailable), we'd want to also skip init/dispose I think, as we weren't able to confirm if the resource is the latest version. Maybe return a (bool, error) here, where err is non-nil on any other error than a conflict error?

Wdyt? Other than that lgtm

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't that just mean that we would want to skip on every error? So we could just return an error and skip if it is non nil.

@roboquat roboquat merged commit c64c4f3 into main Mar 23, 2023
@roboquat roboquat deleted the fo/mk2-daemon-restart branch March 23, 2023 15:31
@roboquat roboquat added deployed: workspace Workspace team change is running in production deployed Change is completely running in production labels Mar 28, 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 feature: ws-manager-mk2 release-note-none size/XL team: workspace Issue belongs to the Workspace team
Projects
No open projects
Status: In Validation
Development

Successfully merging this pull request may close these issues.

3 participants