[arvados] created: 2.1.0-2671-gf67d3bf31

git repository hosting git at public.arvados.org
Fri Jul 1 14:54:11 UTC 2022


        at  f67d3bf3131937389676faebe3322d14a234a55f (commit)


commit f67d3bf3131937389676faebe3322d14a234a55f
Author: Tom Clegg <tom at curii.com>
Date:   Fri Jul 1 10:52:48 2022 -0400

    19235: Add -root flag to load API host/token from config file.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/diagnostics/cmd.go b/lib/diagnostics/cmd.go
index 71fe1c5dc..d0b1d0774 100644
--- a/lib/diagnostics/cmd.go
+++ b/lib/diagnostics/cmd.go
@@ -18,6 +18,7 @@ import (
 	"time"
 
 	"git.arvados.org/arvados.git/lib/cmd"
+	"git.arvados.org/arvados.git/lib/config"
 	"git.arvados.org/arvados.git/sdk/go/arvados"
 	"git.arvados.org/arvados.git/sdk/go/ctxlog"
 	"github.com/sirupsen/logrus"
@@ -32,6 +33,7 @@ func (Command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s
 	f.StringVar(&diag.logLevel, "log-level", "info", "logging level (debug, info, warning, error)")
 	f.BoolVar(&diag.checkInternal, "internal-client", false, "check that this host is considered an \"internal\" client")
 	f.BoolVar(&diag.checkExternal, "external-client", false, "check that this host is considered an \"external\" client")
+	f.BoolVar(&diag.runAsRoot, "root", false, "load controller endpoint and system root token from "+arvados.DefaultConfigFile+" instead of environment vars")
 	f.IntVar(&diag.priority, "priority", 500, "priority for test container (1..1000, or 0 to skip)")
 	f.DurationVar(&diag.timeout, "timeout", 10*time.Second, "timeout for http requests")
 	if ok, code := cmd.ParseFlags(f, prog, args, "", stderr); !ok {
@@ -62,6 +64,7 @@ type diagnoser struct {
 	projectName   string
 	checkInternal bool
 	checkExternal bool
+	runAsRoot     bool
 	timeout       time.Duration
 	logger        *logrus.Logger
 	errors        []string
@@ -112,7 +115,24 @@ func (diag *diagnoser) dotest(id int, title string, fn func() error) {
 func (diag *diagnoser) runtests() {
 	client := arvados.NewClientFromEnv()
 
-	if client.APIHost == "" || client.AuthToken == "" {
+	if diag.runAsRoot {
+		ldr := config.NewLoader(&bytes.Buffer{}, diag.logger)
+		cfg, err := ldr.Load()
+		if err != nil {
+			diag.errorf("error loading host/token from cluster config file: %s", err)
+			return
+		}
+		cluster, err := cfg.GetCluster("")
+		if err != nil {
+			diag.errorf("error loading host/token from cluster config file: %s", err)
+			return
+		}
+		client = &arvados.Client{
+			APIHost:   cluster.Services.Controller.ExternalURL.Host,
+			AuthToken: cluster.SystemRootToken,
+			Insecure:  cluster.TLS.Insecure,
+		}
+	} else if client.APIHost == "" || client.AuthToken == "" {
 		diag.errorf("ARVADOS_API_HOST and ARVADOS_API_TOKEN environment variables are not set -- aborting without running any tests")
 		return
 	}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list