X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5bbec701f90b8179d66e5c308c1c01e3c4dcade7..22cff6bb354d6980c33a0f471d5860f968e853a6:/lib/config/deprecated.go diff --git a/lib/config/deprecated.go b/lib/config/deprecated.go index 9eb8c40c18..d0e61dbca0 100644 --- a/lib/config/deprecated.go +++ b/lib/config/deprecated.go @@ -7,6 +7,7 @@ package config import ( "fmt" "io/ioutil" + "net/url" "os" "strings" @@ -102,12 +103,6 @@ func applyDeprecatedNodeProfile(hostname string, ssi systemServiceInstance, svc svc.InternalURLs[arvados.URL{Scheme: scheme, Host: host}] = arvados.ServiceInstance{} } -const defaultKeepstoreConfigPath = "/etc/arvados/keepstore/keepstore.yml" - -type oldKeepstoreConfig struct { - Debug *bool -} - func (ldr *Loader) loadOldConfigHelper(component, path string, target interface{}) error { if path == "" { return nil @@ -126,35 +121,6 @@ func (ldr *Loader) loadOldConfigHelper(component, path string, target interface{ return nil } -// update config using values from an old-style keepstore config file. -func (ldr *Loader) loadOldKeepstoreConfig(cfg *arvados.Config) error { - if ldr.KeepstorePath == "" { - return nil - } - var oc oldKeepstoreConfig - err := ldr.loadOldConfigHelper("keepstore", ldr.KeepstorePath, &oc) - if os.IsNotExist(err) && (ldr.KeepstorePath == defaultKeepstoreConfigPath) { - return nil - } else if err != nil { - return err - } - - cluster, err := cfg.GetCluster("") - if err != nil { - return err - } - - if v := oc.Debug; v == nil { - } else if *v && cluster.SystemLogs.LogLevel != "debug" { - cluster.SystemLogs.LogLevel = "debug" - } else if !*v && cluster.SystemLogs.LogLevel != "info" { - cluster.SystemLogs.LogLevel = "info" - } - - cfg.Clusters[cluster.ClusterID] = *cluster - return nil -} - type oldCrunchDispatchSlurmConfig struct { Client *arvados.Client @@ -509,3 +475,30 @@ func (ldr *Loader) loadOldGitHttpdConfig(cfg *arvados.Config) error { cfg.Clusters[cluster.ClusterID] = *cluster return nil } + +func (ldr *Loader) loadOldEnvironmentVariables(cfg *arvados.Config) error { + if os.Getenv("ARVADOS_API_TOKEN") == "" && os.Getenv("ARVADOS_API_HOST") == "" { + return nil + } + cluster, err := cfg.GetCluster("") + if err != nil { + return err + } + if tok := os.Getenv("ARVADOS_API_TOKEN"); tok != "" && cluster.SystemRootToken == "" { + ldr.Logger.Warn("SystemRootToken missing from cluster config, falling back to ARVADOS_API_TOKEN environment variable") + cluster.SystemRootToken = tok + } + if apihost := os.Getenv("ARVADOS_API_HOST"); apihost != "" && cluster.Services.Controller.ExternalURL.Host == "" { + ldr.Logger.Warn("Services.Controller.ExternalURL missing from cluster config, falling back to ARVADOS_API_HOST(_INSECURE) environment variables") + u, err := url.Parse("https://" + apihost) + if err != nil { + return fmt.Errorf("cannot parse ARVADOS_API_HOST: %s", err) + } + cluster.Services.Controller.ExternalURL = arvados.URL(*u) + if i := os.Getenv("ARVADOS_API_HOST_INSECURE"); i != "" && i != "0" { + cluster.TLS.Insecure = true + } + } + cfg.Clusters[cluster.ClusterID] = *cluster + return nil +}