15467: Replace KeepServices with SbatchEnvironmentVariables
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 2 Aug 2019 19:00:45 +0000 (15:00 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 2 Aug 2019 19:01:26 +0000 (15:01 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

lib/config/deprecated.go
sdk/go/arvados/config.go
services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go

index 7ae69708eb53d06334b2e732c944f31fb41a3e2d..3d4c252528046b9e281d272bb5264e7b4d06d0be 100644 (file)
@@ -7,7 +7,6 @@ package config
 import (
        "fmt"
        "io/ioutil"
-       "net/url"
        "os"
        "strings"
 
@@ -198,18 +197,14 @@ func loadOldClientConfig(cluster *arvados.Cluster, client *arvados.Client) {
                cluster.SystemRootToken = client.AuthToken
        }
        cluster.TLS.Insecure = client.Insecure
-       for _, r := range client.KeepServiceURIs {
-               if cluster.Containers.SLURM.KeepServices == nil {
-                       cluster.Containers.SLURM.KeepServices = make(map[string]arvados.Service)
-               }
-               if cluster.Containers.SLURM.KeepServices["00000-bi6l4-000000000000000"].InternalURLs == nil {
-                       cluster.Containers.SLURM.KeepServices["00000-bi6l4-000000000000000"] = arvados.Service{InternalURLs: make(map[arvados.URL]arvados.ServiceInstance)}
-               }
-               p, err := url.Parse(r)
-               if err == nil {
-                       cluster.Containers.SLURM.KeepServices["00000-bi6l4-000000000000000"].InternalURLs[arvados.URL(*p)] = struct{}{}
+       ks := ""
+       for i, u := range client.KeepServiceURIs {
+               if i > 0 {
+                       ks += " "
                }
+               ks += u
        }
+       disp.cluster.Containers.SLURM.SbatchEnvironmentVariables = map[string]string{"ARVADOS_KEEP_SERVICES": ks}
 }
 
 // update config using values from an crunch-dispatch-slurm config file.
index f63996437f3ae8989c8511014a2c6ed22b2a5492..f6b736d587c893bc8128875e5889ebfe0ad78be7 100644 (file)
@@ -292,10 +292,10 @@ type ContainersConfig struct {
                LogUpdateSize                ByteSize
        }
        SLURM struct {
-               PrioritySpread      int64
-               SbatchArgumentsList []string
-               KeepServices        map[string]Service
-               Managed             struct {
+               PrioritySpread             int64
+               SbatchArgumentsList        []string
+               SbatchEnvironmentVariables map[string]string
+               Managed                    struct {
                        DNSServerConfDir       string
                        DNSServerConfTemplate  string
                        DNSServerReloadCommand string
index 982141ad81a51269f6d7f110d728d2327227dc71..e4a1e4840b41cbf0385ec38fa12fcde44fd1b853 100644 (file)
@@ -13,7 +13,6 @@ import (
        "fmt"
        "log"
        "math"
-       "net/url"
        "os"
        "regexp"
        "strings"
@@ -133,18 +132,10 @@ func (disp *Dispatcher) configure(prog string, args []string) error {
                if disp.Client.Insecure {
                        os.Setenv("ARVADOS_API_HOST_INSECURE", "1")
                }
-               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", "")
+               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).")
        }
index 63117128eb594e5c492fbe2e93e84c5f77672b1f..ca757af13d94d8d18d622f6e1f6b0646ea7d7bd7 100644 (file)
@@ -420,6 +420,7 @@ BatchSize: 99
                c.Error(err)
 
        }
+       os.Setenv("ARVADOS_KEEP_SERVICES", "")
        err = s.disp.configure("crunch-dispatch-slurm", []string{"-config", tmpfile.Name()})
        c.Check(err, IsNil)
 
@@ -433,16 +434,8 @@ BatchSize: 99
        c.Check(s.disp.cluster.Containers.ReserveExtraRAM, Equals, arvados.ByteSize(12345))
        c.Check(s.disp.cluster.Containers.MinRetryPeriod, Equals, arvados.Duration(13*time.Second))
        c.Check(s.disp.cluster.API.MaxItemsPerResponse, Equals, 99)
-       c.Check(s.disp.cluster.Containers.SLURM.KeepServices, DeepEquals, map[string]arvados.Service{
-               "00000-bi6l4-000000000000000": arvados.Service{
-                       InternalURLs: map[arvados.URL]arvados.ServiceInstance{
-                               arvados.URL{Scheme: "https", Path: "/keep1", Host: "example.com"}: struct{}{},
-                               arvados.URL{Scheme: "https", Path: "/keep2", Host: "example.com"}: struct{}{},
-                       },
-               },
+       c.Check(s.disp.cluster.Containers.SLURM.SbatchEnvironmentVariables, DeepEquals, map[string]string{
+               "ARVADOS_KEEP_SERVICES": "https://example.com/keep1 https://example.com/keep2",
        })
-       ks := os.Getenv("ARVADOS_KEEP_SERVICES")
-       if ks != "https://example.com/keep1 https://example.com/keep2" && ks != "https://example.com/keep2 https://example.com/keep1" {
-               c.Assert(ks, Equals, "https://example.com/keep1 https://example.com/keep2")
-       }
+       c.Check(os.Getenv("ARVADOS_KEEP_SERVICES"), Equals, "https://example.com/keep1 https://example.com/keep2")
 }