X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0c894574ca46b77209127a4908844c2e0e734cea..8fb2167d3f59ed408a413d90e727a39978a5c0a5:/lib/config/cmd.go?ds=inline diff --git a/lib/config/cmd.go b/lib/config/cmd.go index 7889d85c80..347e8519a9 100644 --- a/lib/config/cmd.go +++ b/lib/config/cmd.go @@ -12,7 +12,8 @@ import ( "os" "os/exec" - "git.curoverse.com/arvados.git/sdk/go/ctxlog" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/ctxlog" "github.com/ghodss/yaml" "github.com/sirupsen/logrus" ) @@ -90,6 +91,7 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo flags := flag.NewFlagSet("", flag.ContinueOnError) flags.SetOutput(stderr) loader.SetupFlags(flags) + strict := flags.Bool("strict", true, "Strict validation of configuration file (warnings result in non-zero exit code)") err = flags.Parse(args) if err == flag.ErrHelp { @@ -104,16 +106,30 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo return 2 } + // Load the config twice -- once without loading deprecated + // keys/files, once with -- and then compare the two resulting + // configs. This reveals whether the deprecated keys/files + // have any effect on the final configuration. + // + // If they do, show the operator how to update their config + // such that the deprecated keys/files are superfluous and can + // be deleted. loader.SkipDeprecated = true + loader.SkipLegacy = true withoutDepr, err := loader.Load() if err != nil { return 1 } loader.SkipDeprecated = false + loader.SkipLegacy = false withDepr, err := loader.Load() if err != nil { return 1 } + problems := false + if warnAboutProblems(logger, withDepr) { + problems = true + } 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) @@ -133,19 +149,44 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo fmt.Fprintln(stdout, "Your configuration is relying on deprecated entries. Suggest making the following changes.") stdout.Write(diff) err = nil - return 1 + if *strict { + return 1 + } } else if len(diff) > 0 { fmt.Fprintf(stderr, "Unexpected diff output:\n%s", diff) - return 1 + if *strict { + return 1 + } } else if err != nil { return 1 } if logbuf.Len() > 0 { + if *strict { + return 1 + } + } + + if problems { return 1 } return 0 } +func warnAboutProblems(logger logrus.FieldLogger, cfg *arvados.Config) bool { + warned := false + for id, cc := range cfg.Clusters { + if cc.SystemRootToken == "" { + logger.Warnf("Clusters.%s.SystemRootToken is empty; see https://doc.arvados.org/master/install/install-keepstore.html", id) + warned = true + } + if cc.ManagementToken == "" { + logger.Warnf("Clusters.%s.ManagementToken is empty; see https://doc.arvados.org/admin/management-token.html", id) + warned = true + } + } + return warned +} + var DumpDefaultsCommand defaultsCommand type defaultsCommand struct{}