13647: Don't do API calls while loading controller config.
[arvados.git] / lib / config / load.go
index 84de9b60e991de1672ddb4c448faf860d8ee64fb..93c36f69ed47d0df580f62a137bc44997db718c1 100644 (file)
@@ -28,6 +28,7 @@ type Loader struct {
        Logger         logrus.FieldLogger
        SkipDeprecated bool // Don't load deprecated config keys
        SkipLegacy     bool // Don't load legacy config files
+       SkipAPICalls   bool // Don't do checks that call RailsAPI/controller
 
        Path                    string
        KeepstorePath           string
@@ -35,6 +36,7 @@ type Loader struct {
        CrunchDispatchSlurmPath string
        WebsocketPath           string
        KeepproxyPath           string
+       GitHttpdPath            string
 
        configdata []byte
 }
@@ -66,6 +68,7 @@ func (ldr *Loader) SetupFlags(flagset *flag.FlagSet) {
        flagset.StringVar(&ldr.CrunchDispatchSlurmPath, "legacy-crunch-dispatch-slurm-config", defaultCrunchDispatchSlurmConfigPath, "Legacy crunch-dispatch-slurm configuration `file`")
        flagset.StringVar(&ldr.WebsocketPath, "legacy-ws-config", defaultWebsocketConfigPath, "Legacy arvados-ws configuration `file`")
        flagset.StringVar(&ldr.KeepproxyPath, "legacy-keepproxy-config", defaultKeepproxyConfigPath, "Legacy keepproxy configuration `file`")
+       flagset.StringVar(&ldr.GitHttpdPath, "legacy-git-httpd-config", defaultGitHttpdConfigPath, "Legacy arv-git-httpd configuration `file`")
        flagset.BoolVar(&ldr.SkipLegacy, "skip-legacy", false, "Don't load legacy config files")
 }
 
@@ -143,6 +146,9 @@ func (ldr *Loader) MungeLegacyConfigArgs(lgr logrus.FieldLogger, args []string,
        if legacyConfigArg != "-legacy-keepproxy-config" {
                ldr.KeepproxyPath = ""
        }
+       if legacyConfigArg != "-legacy-git-httpd-config" {
+               ldr.GitHttpdPath = ""
+       }
 
        return munged
 }
@@ -244,6 +250,7 @@ func (ldr *Loader) Load() (*arvados.Config, error) {
                        ldr.loadOldCrunchDispatchSlurmConfig(&cfg),
                        ldr.loadOldWebsocketConfig(&cfg),
                        ldr.loadOldKeepproxyConfig(&cfg),
+                       ldr.loadOldGitHttpdConfig(&cfg),
                } {
                        if err != nil {
                                return nil, err
@@ -253,9 +260,15 @@ func (ldr *Loader) Load() (*arvados.Config, error) {
 
        // Check for known mistakes
        for id, cc := range cfg.Clusters {
-               err = checkKeyConflict(fmt.Sprintf("Clusters.%s.PostgreSQL.Connection", id), cc.PostgreSQL.Connection)
-               if err != nil {
-                       return nil, err
+               for _, err = range []error{
+                       checkKeyConflict(fmt.Sprintf("Clusters.%s.PostgreSQL.Connection", id), cc.PostgreSQL.Connection),
+                       ldr.checkPendingKeepstoreMigrations(cc),
+                       ldr.checkEmptyKeepstores(cc),
+                       ldr.checkUnlistedKeepstores(cc),
+               } {
+                       if err != nil {
+                               return nil, err
+                       }
                }
        }
        return &cfg, nil