15050: After waking up, check if the container was cancelled
[arvados.git] / services / crunch-dispatch-local / crunch-dispatch-local.go
index 62935447dd66643f8f76b6f8bf3a12c0c9b0c678..ae09c52f213f5d17f94445b9ad3c77cea9a21e99 100644 (file)
@@ -155,6 +155,17 @@ func (lr *LocalRun) run(dispatcher *dispatch.Dispatcher,
 
                defer func() { <-lr.concurrencyLimit }()
 
+               select {
+               case c := <-status:
+                       // Check for state updates after possibly
+                       // waiting to be ready-to-run
+                       if c.Priority == 0 {
+                               goto Finish
+                       }
+               default:
+                       break
+               }
+
                waitGroup.Add(1)
                defer waitGroup.Done()
 
@@ -212,6 +223,8 @@ func (lr *LocalRun) run(dispatcher *dispatch.Dispatcher,
                }
        }
 
+Finish:
+
        // If the container is not finalized, then change it to "Cancelled".
        err := dispatcher.Arv.Get("containers", uuid, nil, &container)
        if err != nil {