Merge branch '15370-loopback-dispatchcloud'
[arvados.git] / lib / config / cmd.go
index eeab6ac8cd0dfad10f82f97880db0187f3e412bd..528d748c86f858d353698adc4ae573a569e12c4d 100644 (file)
@@ -6,6 +6,7 @@ package config
 
 import (
        "bytes"
+       "errors"
        "flag"
        "fmt"
        "io"
@@ -13,6 +14,7 @@ import (
        "os/exec"
 
        "git.arvados.org/arvados.git/lib/cmd"
+       "git.arvados.org/arvados.git/sdk/go/arvados"
        "git.arvados.org/arvados.git/sdk/go/ctxlog"
        "github.com/ghodss/yaml"
        "github.com/sirupsen/logrus"
@@ -107,6 +109,34 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
        if err != nil {
                return 1
        }
+
+       // Check for configured vocabulary validity.
+       for id, cc := range withDepr.Clusters {
+               if cc.API.VocabularyPath == "" {
+                       continue
+               }
+               vd, err := os.ReadFile(cc.API.VocabularyPath)
+               if err != nil {
+                       if errors.Is(err, os.ErrNotExist) {
+                               // If the vocabulary path doesn't exist, it might mean that
+                               // the current node isn't the controller; so it's not an
+                               // error.
+                               continue
+                       }
+                       logger.Errorf("Error reading vocabulary file %q for cluster %s: %s\n", cc.API.VocabularyPath, id, err)
+                       continue
+               }
+               mk := make([]string, 0, len(cc.Collections.ManagedProperties))
+               for k := range cc.Collections.ManagedProperties {
+                       mk = append(mk, k)
+               }
+               _, err = arvados.NewVocabulary(vd, mk)
+               if err != nil {
+                       logger.Errorf("Error loading vocabulary file %q for cluster %s:\n%s\n", cc.API.VocabularyPath, id, err)
+                       continue
+               }
+       }
+
        cmd := exec.Command("diff", "-u", "--label", "without-deprecated-configs", "--label", "relying-on-deprecated-configs", "/dev/fd/3", "/dev/fd/4")
        for _, obj := range []interface{}{withoutDepr, withDepr} {
                y, _ := yaml.Marshal(obj)