Merge branch '9307-cwl-use-tmp-output' closes #9307 closes #9308
[arvados.git] / services / crunch-dispatch-local / crunch-dispatch-local.go
index cc472a40311adc36f91202512c3f4f7fb52e2b8f..0ca765185119c152dd11870641c15f905042311e 100644 (file)
@@ -4,6 +4,7 @@ package main
 
 import (
        "flag"
+       "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/dispatch"
        "log"
@@ -76,7 +77,7 @@ func doMain() error {
        return nil
 }
 
-func startFunc(container dispatch.Container, cmd *exec.Cmd) error {
+func startFunc(container arvados.Container, cmd *exec.Cmd) error {
        return cmd.Start()
 }
 
@@ -91,8 +92,8 @@ var startCmd = startFunc
 // If the container is in any other state, or is not Complete/Cancelled after
 // crunch-run terminates, mark the container as Cancelled.
 func run(dispatcher *dispatch.Dispatcher,
-       container dispatch.Container,
-       status chan dispatch.Container) {
+       container arvados.Container,
+       status chan arvados.Container) {
 
        uuid := container.UUID
 
@@ -159,14 +160,15 @@ func run(dispatcher *dispatch.Dispatcher,
        if err != nil {
                log.Printf("Error getting final container state: %v", err)
        }
-       if container.State != dispatch.Complete && container.State != dispatch.Cancelled {
+       if container.LockedByUUID == dispatcher.Auth.UUID &&
+               (container.State == dispatch.Locked || container.State == dispatch.Running) {
                log.Printf("After %s process termination, container state for %v is %q.  Updating it to %q",
                        *crunchRunCommand, container.State, uuid, dispatch.Cancelled)
                dispatcher.UpdateState(uuid, dispatch.Cancelled)
        }
 
        // drain any subsequent status changes
-       for _ = range status {
+       for range status {
        }
 
        log.Printf("Finalized container %v", uuid)