Skip to content
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

[ws-daemon] Re-establish IWS on restart #5130

Merged
merged 2 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .werft/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export async function deployToDev(deploymentConfig: DeploymentConfig, workspaceF
let flags = ""
flags += ` --namespace ${namespace}`;
flags += ` --set components.imageBuilder.hostDindData=/mnt/disks/ssd0/docker-${namespace}`;
flags += ` --set components.wsDaemon.hostWorkspaceArea=/mnt/disks/ssd0/workspaces-${namespace}`;
flags += ` --set version=${version}`;
flags += ` --set hostname=${domain}`;
flags += ` --set devBranch=${destname}`;
Expand Down
8 changes: 6 additions & 2 deletions components/ws-daemon/pkg/content/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,13 @@ func workspaceLifecycleHooks(cfg Config, kubernetesNamespace string, workspaceEx
return nil
}

// startIWS starts the in-workspace service for a workspace. This lifecycle hook is idempotent, hence can - and must -
// be called on initialization and ready. The on-ready hook exists only to support ws-daemon restarts.
startIWS := iws.ServeWorkspace(uidmapper, api.FSShiftMethod(cfg.UserNamespaces.FSShift))

return map[session.WorkspaceState][]session.WorkspaceLivecycleHook{
session.WorkspaceInitializing: {setupWorkspace, iws.ServeWorkspace(uidmapper, api.FSShiftMethod(cfg.UserNamespaces.FSShift))},
session.WorkspaceReady: {setupWorkspace},
session.WorkspaceInitializing: {setupWorkspace, startIWS},
session.WorkspaceReady: {setupWorkspace, startIWS},
session.WorkspaceDisposing: {iws.StopServingWorkspace},
}
}
4 changes: 4 additions & 0 deletions components/ws-daemon/pkg/iws/iws.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ var (
// ServeWorkspace establishes the IWS server for a workspace
func ServeWorkspace(uidmapper *Uidmapper, fsshift api.FSShiftMethod) func(ctx context.Context, ws *session.Workspace) error {
return func(ctx context.Context, ws *session.Workspace) (err error) {
if _, running := ws.NonPersistentAttrs[session.AttrWorkspaceServer]; running {
return nil
}

//nolint:ineffassign
span, ctx := opentracing.StartSpanFromContext(ctx, "iws.ServeWorkspace")
defer tracing.FinishSpan(span, &err)
Expand Down