X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/72a8b3582d925ea30fe78697ff76bafb20d8bd9e..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 75e6146f53..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" @@ -18,14 +17,14 @@ import ( "strings" "time" - "git.curoverse.com/arvados.git/lib/config" - "git.curoverse.com/arvados.git/lib/dispatchcloud" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/arvadosclient" - "git.curoverse.com/arvados.git/sdk/go/dispatch" + "git.arvados.org/arvados.git/lib/config" + "git.arvados.org/arvados.git/lib/dispatchcloud" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadosclient" + "git.arvados.org/arvados.git/sdk/go/dispatch" "github.com/coreos/go-systemd/daemon" + "github.com/ghodss/yaml" "github.com/sirupsen/logrus" - "gopkg.in/yaml.v2" ) type logger interface { @@ -109,7 +108,6 @@ func (disp *Dispatcher) configure(prog string, args []string) error { disp.logger.Printf("crunch-dispatch-slurm %s started", version) - loader.LegacyComponentConfig = loader.CrunchDispatchSlurmPath cfg, err := loader.Load() if err != nil { return err @@ -133,8 +131,10 @@ func (disp *Dispatcher) configure(prog string, args []string) error { if disp.Client.Insecure { os.Setenv("ARVADOS_API_HOST_INSECURE", "1") } - os.Setenv("ARVADOS_KEEP_SERVICES", strings.Join(disp.Client.KeepServiceURIs, " ")) os.Setenv("ARVADOS_EXTERNAL_CLIENT", "") + for k, v := range disp.cluster.Containers.SLURM.SbatchEnvironmentVariables { + os.Setenv(k, v) + } } else { disp.logger.Warnf("Client credentials missing from config, so falling back on environment variables (deprecated).") } @@ -201,7 +201,7 @@ var containerUuidPattern = regexp.MustCompile(`^[a-z0-9]{5}-dz642-[a-z0-9]{15}$` // Cancelled or Complete. See https://dev.arvados.org/issues/10979 func (disp *Dispatcher) checkSqueueForOrphans() { for _, uuid := range disp.sqCheck.All() { - if !containerUuidPattern.MatchString(uuid) { + if !containerUuidPattern.MatchString(uuid) || !strings.HasPrefix(uuid, disp.cluster.ClusterID) { continue } err := disp.TrackContainer(uuid) @@ -254,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)) @@ -269,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() @@ -277,37 +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 - if err, ok := err.(dispatchcloud.ConstraintsNotSatisfiableError); ok { - 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) - } else { - 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 } } @@ -336,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)