X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f8b5741b4f39e01862837a553b3b9b24089c110e..6d8326a0f1521b0d7c49cd90dc775d409906bc49:/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go index a5899ce8a7..584db38edf 100644 --- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go +++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go @@ -7,7 +7,6 @@ package main // Dispatcher service for Crunch that submits containers to the slurm queue. import ( - "bytes" "context" "flag" "fmt" @@ -255,6 +254,7 @@ func (disp *Dispatcher) submit(container arvados.Container, crunchRunCommand []s // append() here avoids modifying crunchRunCommand's // underlying array, which is shared with other goroutines. crArgs := append([]string(nil), crunchRunCommand...) + crArgs = append(crArgs, "--runtime-engine="+disp.cluster.Containers.RuntimeEngine) crArgs = append(crArgs, container.UUID) crScript := strings.NewReader(execScript(crArgs)) @@ -270,7 +270,7 @@ func (disp *Dispatcher) submit(container arvados.Container, crunchRunCommand []s // already in the queue). Cancel the slurm job if the container's // priority changes to zero or its state indicates it's no longer // running. -func (disp *Dispatcher) runContainer(_ *dispatch.Dispatcher, ctr arvados.Container, status <-chan arvados.Container) { +func (disp *Dispatcher) runContainer(_ *dispatch.Dispatcher, ctr arvados.Container, status <-chan arvados.Container) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -278,38 +278,9 @@ func (disp *Dispatcher) runContainer(_ *dispatch.Dispatcher, ctr arvados.Contain log.Printf("Submitting container %s to slurm", ctr.UUID) cmd := []string{disp.cluster.Containers.CrunchRunCommand} cmd = append(cmd, disp.cluster.Containers.CrunchRunArgumentsList...) - if err := disp.submit(ctr, cmd); err != nil { - var text string - switch err := err.(type) { - case dispatchcloud.ConstraintsNotSatisfiableError: - var logBuf bytes.Buffer - fmt.Fprintf(&logBuf, "cannot run container %s: %s\n", ctr.UUID, err) - if len(err.AvailableTypes) == 0 { - fmt.Fprint(&logBuf, "No instance types are configured.\n") - } else { - fmt.Fprint(&logBuf, "Available instance types:\n") - for _, t := range err.AvailableTypes { - fmt.Fprintf(&logBuf, - "Type %q: %d VCPUs, %d RAM, %d Scratch, %f Price\n", - t.Name, t.VCPUs, t.RAM, t.Scratch, t.Price, - ) - } - } - text = logBuf.String() - disp.UpdateState(ctr.UUID, dispatch.Cancelled) - default: - text = fmt.Sprintf("Error submitting container %s to slurm: %s", ctr.UUID, err) - } - log.Print(text) - - lr := arvadosclient.Dict{"log": arvadosclient.Dict{ - "object_uuid": ctr.UUID, - "event_type": "dispatch", - "properties": map[string]string{"text": text}}} - disp.Arv.Create("logs", lr, nil) - - disp.Unlock(ctr.UUID) - return + err := disp.submit(ctr, cmd) + if err != nil { + return err } } @@ -338,7 +309,7 @@ func (disp *Dispatcher) runContainer(_ *dispatch.Dispatcher, ctr arvados.Contain case dispatch.Locked: disp.Unlock(ctr.UUID) } - return + return nil case updated, ok := <-status: if !ok { log.Printf("container %s is done: cancel slurm job", ctr.UUID)