Skip to content

Commit

Permalink
[ws-daemon] Check for workspace state
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Aug 17, 2021
1 parent e7f165a commit 551e6d4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/ws-daemon/pkg/dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ func (d *Dispatch) Close() error {
defer d.mu.Unlock()

close(d.stopchan)
for _, c := range d.ctxs {
c.Cancel()
for _, state := range d.ctxs {
if state != nil && state.Cancel != nil {
state.Cancel()
}
}

d.ctxs = make(map[string]*workspaceState)

return nil
Expand Down Expand Up @@ -231,7 +234,11 @@ func (d *Dispatch) handlePodUpdate(oldPod, newPod *corev1.Pod) {
go func() {
// no matter if the container was deleted or not - we've lost our guard that was waiting for that to happen.
// Hence, we must stop listening for it to come into existence and cancel the context.
d.Runtime.WaitForContainerStop(waitForPodCtx, workspaceInstanceID)
err := d.Runtime.WaitForContainerStop(waitForPodCtx, workspaceInstanceID)
if err != nil {
log.WithError(err).WithFields(owi).Error("unexpected waiting for container to stop")
}

cancel()
}()

Expand Down

0 comments on commit 551e6d4

Please sign in to comment.