9745: Load API host and token from crunch-dispatch-slurm config file.
authorTom Clegg <tom@curoverse.com>
Fri, 5 Aug 2016 15:44:29 +0000 (11:44 -0400)
committerTom Clegg <tom@curoverse.com>
Fri, 5 Aug 2016 15:44:29 +0000 (11:44 -0400)
services/crunch-dispatch-slurm/crunch-dispatch-slurm.go

index b11963c7040ac7e1ad0d5ce42e983c54f1bb5624..1d9015d5051f0a678a834ba56781377d39a4b96c 100644 (file)
@@ -21,6 +21,8 @@ import (
 
 // Config used by crunch-dispatch-slurm
 type Config struct {
+       arvados.Client
+
        SbatchArguments []string
        PollPeriod      arvados.Duration
 
@@ -71,6 +73,22 @@ func doMain() error {
                config.PollPeriod = arvados.Duration(10 * time.Second)
        }
 
+       if config.Client.APIHost != "" || config.Client.AuthToken != "" {
+               // Copy real configs into env vars so [a]
+               // MakeArvadosClient() uses them, and [b] they get
+               // propagated to crunch-run via SLURM.
+               os.Setenv("ARVADOS_API_HOST", config.Client.APIHost)
+               os.Setenv("ARVADOS_API_TOKEN", config.Client.AuthToken)
+               os.Setenv("ARVADOS_API_INSECURE", "")
+               if config.Client.Insecure {
+                       os.Setenv("ARVADOS_API_INSECURE", "1")
+               }
+               os.Setenv("ARVADOS_KEEP_SERVICES", "")
+               os.Setenv("ARVADOS_EXTERNAL_CLIENT", "")
+       } else {
+               log.Printf("warning: Client credentials missing from config, so falling back on environment variables (deprecated).")
+       }
+
        arv, err := arvadosclient.MakeArvadosClient()
        if err != nil {
                log.Printf("Error making Arvados client: %v", err)