X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c95847885fd858916dac6d8a7c4f0b364f9db340..1535c8d141b07f246a501d288a0d3a903ce41a56:/services/crunch-dispatch-local/crunch-dispatch-local.go diff --git a/services/crunch-dispatch-local/crunch-dispatch-local.go b/services/crunch-dispatch-local/crunch-dispatch-local.go index 47c3564502..e05c0c5da4 100644 --- a/services/crunch-dispatch-local/crunch-dispatch-local.go +++ b/services/crunch-dispatch-local/crunch-dispatch-local.go @@ -75,13 +75,8 @@ func doMain() error { runQueuedContainers(*pollInterval, *priorityPollInterval, *crunchRunCommand) // Finished dispatching; interrupt any crunch jobs that are still running - for uuid, cmd := range runningCmds { - go func(uuid string) { - cmd.Process.Signal(os.Interrupt) - if _, err := cmd.Process.Wait(); err != nil { - log.Printf("Error while waiting for crunch job to finish for %v: %q", uuid, err) - } - }(uuid) + for _, cmd := range runningCmds { + cmd.Process.Signal(os.Interrupt) } // Wait for all running crunch jobs to complete / terminate @@ -181,22 +176,15 @@ func run(uuid string, crunchRunCommand string, priorityPollInterval int) { // A goroutine to terminate the runner if container priority becomes zero priorityTicker := time.NewTicker(time.Duration(priorityPollInterval) * time.Second) go func() { - for { - select { - case <-priorityTicker.C: - var container Container - err := arv.Get("containers", uuid, nil, &container) - if err != nil { - log.Printf("Error getting container info for %v: %q", uuid, err) - } else { - if container.Priority == 0 { - priorityTicker.Stop() - cmd.Process.Signal(os.Interrupt) - runningCmdsMutex.Lock() - delete(runningCmds, uuid) - runningCmdsMutex.Unlock() - return - } + for _ = range priorityTicker.C { + var container Container + err := arv.Get("containers", uuid, nil, &container) + if err != nil { + log.Printf("Error getting container info for %v: %q", uuid, err) + } else { + if container.Priority == 0 { + priorityTicker.Stop() + cmd.Process.Signal(os.Interrupt) } } } @@ -227,4 +215,6 @@ func run(uuid string, crunchRunCommand string, priorityPollInterval int) { log.Printf("Error updating container state to Complete for %v: %q", uuid, err) } } + + log.Printf("Finished container run for %v", uuid) }