18487: Logs vocabulary validating error messages along with other checks.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Mon, 24 Jan 2022 20:18:07 +0000 (17:18 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Mon, 24 Jan 2022 20:18:07 +0000 (17:18 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

lib/config/cmd.go
lib/config/cmd_test.go

index 56a74a21c2a9f41dc1710c468e162a6f60f10231..528d748c86f858d353698adc4ae573a569e12c4d 100644 (file)
@@ -109,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)
@@ -144,31 +172,6 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
                        return 1
                }
        }
-       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
-                       }
-                       fmt.Fprintf(stderr, "Error reading vocabulary file %q for cluster %s: %s\n", cc.API.VocabularyPath, id, err)
-                       return 1
-               }
-               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 {
-                       fmt.Fprintf(stderr, "Error loading vocabulary file %q for cluster %s:\n%s\n", cc.API.VocabularyPath, id, err)
-                       return 1
-               }
-       }
        return 0
 }
 
index 2bb596a05adc1d936597fa2ad3568be7f77f5150..7167982ccd7021f3b43a895190909694c493b7da 100644 (file)
@@ -129,7 +129,7 @@ Clusters:
 `
        code := CheckCommand.RunCommand("arvados config-check", []string{"-config", "-"}, bytes.NewBufferString(in), &stdout, &stderr)
        c.Check(code, check.Equals, 1)
-       c.Check(stderr.String(), check.Matches, `(?s).*Error loading vocabulary file.*for cluster.*\nduplicate JSON key "tags.IDfoo".*`)
+       c.Check(stderr.String(), check.Matches, `(?ms).*Error loading vocabulary file.*for cluster.*duplicate JSON key.*tags.IDfoo.*`)
 }
 
 func (s *CommandSuite) TestCheck_DeprecatedKeys(c *check.C) {