15467: Added tests for KeepServices
[arvados.git] / services / crunch-dispatch-slurm / crunch-dispatch-slurm.go
index 75e6146f530ac6f580c4789eb20f8e8b144e9286..982141ad81a51269f6d7f110d728d2327227dc71 100644 (file)
@@ -13,6 +13,7 @@ import (
        "fmt"
        "log"
        "math"
+       "net/url"
        "os"
        "regexp"
        "strings"
@@ -24,8 +25,8 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/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 +110,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,7 +133,17 @@ 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, " "))
+               ks := ""
+               if len(disp.cluster.Containers.SLURM.KeepServices) > 0 {
+                       for _, svc := range disp.cluster.Containers.SLURM.KeepServices {
+                               for k, _ := range svc.InternalURLs {
+                                       u := url.URL(k)
+                                       ks += u.String()
+                                       ks += " "
+                               }
+                       }
+               }
+               os.Setenv("ARVADOS_KEEP_SERVICES", strings.TrimSuffix(ks, " "))
                os.Setenv("ARVADOS_EXTERNAL_CLIENT", "")
        } else {
                disp.logger.Warnf("Client credentials missing from config, so falling back on environment variables (deprecated).")