@@ -82,10 +82,10 @@ type Dispatch struct {
82
82
}
83
83
84
84
type workspaceState struct {
85
- SeenContainer bool
86
- Context context.Context
87
- Cancel context.CancelFunc
88
- Workspace * Workspace
85
+ WorkspaceAdded bool
86
+ Context context.Context
87
+ Cancel context.CancelFunc
88
+ Workspace * Workspace
89
89
}
90
90
91
91
type contextKey struct {}
@@ -191,7 +191,7 @@ func (d *Dispatch) handlePodUpdate(oldPod, newPod *corev1.Pod) {
191
191
// we haven't seen this pod before - add it, and wait for the container
192
192
owi := wsk8s .GetOWIFromObject (& newPod .ObjectMeta )
193
193
d .ctxs [workspaceInstanceID ] = & workspaceState {
194
- SeenContainer : false ,
194
+ WorkspaceAdded : false ,
195
195
Workspace : & Workspace {
196
196
InstanceID : workspaceInstanceID ,
197
197
WorkspaceID : workspaceID ,
@@ -220,8 +220,6 @@ func (d *Dispatch) handlePodUpdate(oldPod, newPod *corev1.Pod) {
220
220
s .Context = containerCtx
221
221
s .Cancel = containerCtxCancel
222
222
s .Workspace .ContainerID = containerID
223
- s .SeenContainer = true
224
- d .mu .Unlock ()
225
223
226
224
for _ , l := range d .Listener {
227
225
go func (listener Listener ) {
@@ -231,6 +229,9 @@ func (d *Dispatch) handlePodUpdate(oldPod, newPod *corev1.Pod) {
231
229
}
232
230
}(l )
233
231
}
232
+
233
+ s .WorkspaceAdded = true
234
+ d .mu .Unlock ()
234
235
}()
235
236
go func () {
236
237
// no matter if the container was deleted or not - we've lost our guard that was waiting for that to happen.
@@ -246,7 +247,7 @@ func (d *Dispatch) handlePodUpdate(oldPod, newPod *corev1.Pod) {
246
247
return
247
248
}
248
249
249
- if ! state .SeenContainer {
250
+ if ! state .WorkspaceAdded {
250
251
return
251
252
}
252
253
0 commit comments