Skip to content

Commit 3d313d2

Browse files
csweichelroboquat
authored andcommitted
[ws-daemon] Serve IWS on restart
1 parent 026665e commit 3d313d2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

components/ws-daemon/pkg/content/service.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,13 @@ func workspaceLifecycleHooks(cfg Config, kubernetesNamespace string, workspaceEx
754754
return nil
755755
}
756756

757+
// startIWS starts the in-workspace service for a workspace. This lifecycle hook is idempotent, hence can - and must -
758+
// be called on initialization and ready. The on-ready hook exists only to support ws-daemon restarts.
759+
startIWS := iws.ServeWorkspace(uidmapper, api.FSShiftMethod(cfg.UserNamespaces.FSShift))
760+
757761
return map[session.WorkspaceState][]session.WorkspaceLivecycleHook{
758-
session.WorkspaceInitializing: {setupWorkspace, iws.ServeWorkspace(uidmapper, api.FSShiftMethod(cfg.UserNamespaces.FSShift))},
759-
session.WorkspaceReady: {setupWorkspace},
762+
session.WorkspaceInitializing: {setupWorkspace, startIWS},
763+
session.WorkspaceReady: {setupWorkspace, startIWS},
760764
session.WorkspaceDisposing: {iws.StopServingWorkspace},
761765
}
762766
}

components/ws-daemon/pkg/iws/iws.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ var (
7878
// ServeWorkspace establishes the IWS server for a workspace
7979
func ServeWorkspace(uidmapper *Uidmapper, fsshift api.FSShiftMethod) func(ctx context.Context, ws *session.Workspace) error {
8080
return func(ctx context.Context, ws *session.Workspace) (err error) {
81+
if _, running := ws.NonPersistentAttrs[session.AttrWorkspaceServer]; running {
82+
return nil
83+
}
84+
8185
//nolint:ineffassign
8286
span, ctx := opentracing.StartSpanFromContext(ctx, "iws.ServeWorkspace")
8387
defer tracing.FinishSpan(span, &err)

0 commit comments

Comments
 (0)