[ARVADOS] created: 2.1.0-651-ge01a688f1

Git user git at public.arvados.org
Wed Apr 14 20:52:50 UTC 2021


        at  e01a688f1e9634c8a9032bd6e78d34ebd47e2c3a (commit)


commit e01a688f1e9634c8a9032bd6e78d34ebd47e2c3a
Author: Nico Cesar <nico at nicocesar.com>
Date:   Wed Apr 14 16:51:36 2021 -0400

    Adding error to NewClientFromEnv() in case vars are missing
    
    Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico at curii.com>

diff --git a/cmd/arvados-client/container_gateway_test.go b/cmd/arvados-client/container_gateway_test.go
index 97a615e4b..d935d824d 100644
--- a/cmd/arvados-client/container_gateway_test.go
+++ b/cmd/arvados-client/container_gateway_test.go
@@ -35,7 +35,9 @@ func (s *ClientSuite) TestShellGatewayNotAvailable(c *check.C) {
 
 func (s *ClientSuite) TestShellGateway(c *check.C) {
 	defer func() {
-		c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
+		client, err := arvados.NewClientFromEnv()
+		c.Assert(err, check.IsNil)
+		c.Check(client.RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
 	}()
 	uuid := arvadostest.QueuedContainerUUID
 	h := hmac.New(sha256.New, []byte(arvadostest.SystemRootToken))
diff --git a/lib/cli/get.go b/lib/cli/get.go
index 9625214e2..5f07828b8 100644
--- a/lib/cli/get.go
+++ b/lib/cli/get.go
@@ -42,7 +42,10 @@ func (getCmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, st
 	}
 
 	id := flags.Args()[0]
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	if err != nil {
+		return 1
+	}
 	path, err := client.PathForUUID("show", id)
 	if err != nil {
 		return 1
diff --git a/lib/config/deprecated_keepstore_test.go b/lib/config/deprecated_keepstore_test.go
index dab308c9d..fddbab708 100644
--- a/lib/config/deprecated_keepstore_test.go
+++ b/lib/config/deprecated_keepstore_test.go
@@ -39,11 +39,11 @@ func (s *KeepstoreMigrationSuite) SetUpSuite(c *check.C) {
 	// the apiserver fixtures that point to fictional hosts
 	// keep*.zzzzz.arvadosapi.com.
 
-	client := arvados.NewClientFromEnv()
-
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	// Delete existing non-proxy listings.
 	var svcList arvados.KeepServiceList
-	err := client.RequestAndDecode(&svcList, "GET", "arvados/v1/keep_services", nil, nil)
+	err = client.RequestAndDecode(&svcList, "GET", "arvados/v1/keep_services", nil, nil)
 	c.Assert(err, check.IsNil)
 	for _, ks := range svcList.Items {
 		if ks.ServiceType != "proxy" {
@@ -580,7 +580,8 @@ Volumes:
 
 // Ensure logs mention unmigrated servers.
 func (s *KeepstoreMigrationSuite) TestPendingKeepstoreMigrations(c *check.C) {
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	for _, host := range []string{"keep0", "keep1"} {
 		err := client.RequestAndDecode(new(struct{}), "POST", "arvados/v1/keep_services", nil, map[string]interface{}{
 			"keep_service": map[string]interface{}{
diff --git a/lib/controller/localdb/container_gateway_test.go b/lib/controller/localdb/container_gateway_test.go
index aff569b09..44e9d8df3 100644
--- a/lib/controller/localdb/container_gateway_test.go
+++ b/lib/controller/localdb/container_gateway_test.go
@@ -35,7 +35,9 @@ func (s *ContainerGatewaySuite) TearDownSuite(c *check.C) {
 	// Undo any changes/additions to the user database so they
 	// don't affect subsequent tests.
 	arvadostest.ResetEnv()
-	c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
+	c.Check(client.RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
 }
 
 func (s *ContainerGatewaySuite) SetUpSuite(c *check.C) {
diff --git a/lib/controller/localdb/login_ldap_test.go b/lib/controller/localdb/login_ldap_test.go
index b8ba6b467..efefb0da3 100644
--- a/lib/controller/localdb/login_ldap_test.go
+++ b/lib/controller/localdb/login_ldap_test.go
@@ -39,7 +39,9 @@ func (s *LDAPSuite) TearDownSuite(c *check.C) {
 	// Undo any changes/additions to the user database so they
 	// don't affect subsequent tests.
 	arvadostest.ResetEnv()
-	c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	c.Check(client.RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
 }
 
 func (s *LDAPSuite) SetUpSuite(c *check.C) {
diff --git a/lib/controller/localdb/login_oidc_test.go b/lib/controller/localdb/login_oidc_test.go
index e3c72addd..480d30a23 100644
--- a/lib/controller/localdb/login_oidc_test.go
+++ b/lib/controller/localdb/login_oidc_test.go
@@ -48,7 +48,9 @@ func (s *OIDCLoginSuite) TearDownSuite(c *check.C) {
 	// Undo any changes/additions to the user database so they
 	// don't affect subsequent tests.
 	arvadostest.ResetEnv()
-	c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
+	c.Check(client.RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
 }
 
 func (s *OIDCLoginSuite) SetUpTest(c *check.C) {
diff --git a/lib/controller/router/router_test.go b/lib/controller/router/router_test.go
index 18fff7c9c..dc9043c2b 100644
--- a/lib/controller/router/router_test.go
+++ b/lib/controller/router/router_test.go
@@ -173,7 +173,9 @@ func (s *RouterIntegrationSuite) SetUpTest(c *check.C) {
 }
 
 func (s *RouterIntegrationSuite) TearDownSuite(c *check.C) {
-	err := arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil)
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	err = client.RequestAndDecode(nil, "POST", "database/reset", nil, nil)
 	c.Check(err, check.IsNil)
 }
 
diff --git a/lib/costanalyzer/costanalyzer.go b/lib/costanalyzer/costanalyzer.go
index 37e655e53..1b61b161a 100644
--- a/lib/costanalyzer/costanalyzer.go
+++ b/lib/costanalyzer/costanalyzer.go
@@ -9,10 +9,6 @@ import (
 	"errors"
 	"flag"
 	"fmt"
-	"git.arvados.org/arvados.git/lib/config"
-	"git.arvados.org/arvados.git/sdk/go/arvados"
-	"git.arvados.org/arvados.git/sdk/go/arvadosclient"
-	"git.arvados.org/arvados.git/sdk/go/keepclient"
 	"io"
 	"io/ioutil"
 	"net/http"
@@ -21,6 +17,11 @@ import (
 	"strings"
 	"time"
 
+	"git.arvados.org/arvados.git/lib/config"
+	"git.arvados.org/arvados.git/sdk/go/arvados"
+	"git.arvados.org/arvados.git/sdk/go/arvadosclient"
+	"git.arvados.org/arvados.git/sdk/go/keepclient"
+
 	"github.com/sirupsen/logrus"
 )
 
@@ -497,8 +498,12 @@ func costanalyzer(prog string, args []string, loader *config.Loader, logger *log
 		return
 	}
 
-	ac := arvados.NewClientFromEnv()
-
+	ac, err := arvados.NewClientFromEnv()
+	if err != nil {
+		err = fmt.Errorf("error creating client from environment: %s", err)
+		exitcode = 1
+		return
+	}
 	cost := make(map[string]float64)
 	for _, uuid := range uuids {
 		if strings.Contains(uuid, "-j7d0g-") {
diff --git a/lib/costanalyzer/costanalyzer_test.go b/lib/costanalyzer/costanalyzer_test.go
index f4d8d1073..6469b6307 100644
--- a/lib/costanalyzer/costanalyzer_test.go
+++ b/lib/costanalyzer/costanalyzer_test.go
@@ -37,7 +37,8 @@ func (s *Suite) SetUpSuite(c *check.C) {
 	arvadostest.StartKeep(2, true)
 
 	// Get the various arvados, arvadosclient, and keep client objects
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.Equals, nil)
 	arv, err := arvadosclient.MakeArvadosClient()
 	c.Assert(err, check.Equals, nil)
 	arv.ApiToken = arvadostest.ActiveToken
@@ -190,11 +191,12 @@ func (*Suite) TestCollectionUUID(c *check.C) {
 	c.Assert(stderr.String(), check.Matches, "(?ms).*does not have a 'container_request' property.*")
 
 	// Update the collection, attach a 'container_request' property
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
 	var coll arvados.Collection
 
 	// Update collection record
-	err := ac.RequestAndDecode(&coll, "PUT", "arvados/v1/collections/"+arvadostest.FooCollection, nil, map[string]interface{}{
+	err = ac.RequestAndDecode(&coll, "PUT", "arvados/v1/collections/"+arvadostest.FooCollection, nil, map[string]interface{}{
 		"collection": map[string]interface{}{
 			"properties": map[string]interface{}{
 				"container_request": arvadostest.CompletedContainerRequestUUID,
@@ -252,7 +254,8 @@ func (*Suite) TestDoubleContainerRequestUUID(c *check.C) {
 
 	// Now move both container requests into an existing project, and then re-run
 	// the analysis with the project uuid. The results should be identical.
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	var cr arvados.ContainerRequest
 	err = ac.RequestAndDecode(&cr, "PUT", "arvados/v1/container_requests/"+arvadostest.CompletedContainerRequestUUID, nil, map[string]interface{}{
 		"container_request": map[string]interface{}{
diff --git a/lib/crunchrun/copier_test.go b/lib/crunchrun/copier_test.go
index 777b715d7..484f19720 100644
--- a/lib/crunchrun/copier_test.go
+++ b/lib/crunchrun/copier_test.go
@@ -26,8 +26,10 @@ func (s *copierSuite) SetUpTest(c *check.C) {
 	c.Assert(err, check.IsNil)
 	api, err := arvadosclient.MakeArvadosClient()
 	c.Assert(err, check.IsNil)
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	s.cp = copier{
-		client:        arvados.NewClientFromEnv(),
+		client:        client,
 		arvClient:     api,
 		hostOutputDir: tmpdir,
 		ctrOutputDir:  "/ctr/outdir",
diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index 969682f46..5cef659cc 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -1749,7 +1749,10 @@ func NewContainerRunner(dispatcherClient *arvados.Client,
 		if err != nil {
 			return nil, nil, nil, err
 		}
-		c2 := arvados.NewClientFromEnv()
+		c2, err := arvados.NewClientFromEnv()
+		if err != nil {
+			return nil, nil, nil, err
+		}
 		c2.AuthToken = token
 		return cl, kc, c2, nil
 	}
@@ -1867,7 +1870,12 @@ func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s
 	// minimum version we want to support.
 	docker, dockererr := dockerclient.NewClient(dockerclient.DefaultDockerHost, "1.21", nil, nil)
 
-	cr, err := NewContainerRunner(arvados.NewClientFromEnv(), api, kc, docker, containerID)
+	client, err := arvados.NewClientFromEnv()
+	if err != nil {
+		log.Print(err)
+		return 1
+	}
+	cr, err := NewContainerRunner(client, api, kc, docker, containerID)
 	if err != nil {
 		log.Print(err)
 		return 1
diff --git a/lib/crunchrun/crunchrun_test.go b/lib/crunchrun/crunchrun_test.go
index dbdaa6293..f94a09ed2 100644
--- a/lib/crunchrun/crunchrun_test.go
+++ b/lib/crunchrun/crunchrun_test.go
@@ -33,6 +33,7 @@ import (
 	dockertypes "github.com/docker/docker/api/types"
 	dockercontainer "github.com/docker/docker/api/types/container"
 	dockernetwork "github.com/docker/docker/api/types/network"
+	"gopkg.in/check.v1"
 	. "gopkg.in/check.v1"
 )
 
@@ -51,7 +52,9 @@ type TestSuite struct {
 }
 
 func (s *TestSuite) SetUpTest(c *C) {
-	s.client = arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	s.client = client
 	s.docker = NewTestDockerClient()
 }
 
diff --git a/lib/crunchrun/logging_test.go b/lib/crunchrun/logging_test.go
index e3fa3af0b..3556a8baf 100644
--- a/lib/crunchrun/logging_test.go
+++ b/lib/crunchrun/logging_test.go
@@ -36,7 +36,10 @@ func (stamper *TestTimestamper) Timestamp(t time.Time) string {
 var _ = Suite(&LoggingTestSuite{})
 
 func (s *LoggingTestSuite) SetUpTest(c *C) {
-	s.client = arvados.NewClientFromEnv()
+
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, IsNil)
+	s.client = client
 	crunchLogUpdatePeriod = time.Hour * 24 * 365
 	crunchLogUpdateSize = 1 << 50
 }
diff --git a/lib/deduplicationreport/report_test.go b/lib/deduplicationreport/report_test.go
index e172008c7..67f533a8c 100644
--- a/lib/deduplicationreport/report_test.go
+++ b/lib/deduplicationreport/report_test.go
@@ -83,10 +83,10 @@ func (*Suite) TestManyUUIDsNoOverlap(c *check.C) {
 func (*Suite) TestTwoOverlappingCollections(c *check.C) {
 	var stdout, stderr bytes.Buffer
 	// Create two collections
-	arv := arvados.NewClientFromEnv()
-
+	arv, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.Equals, nil)
 	var c1 arvados.Collection
-	err := arv.RequestAndDecode(&c1, "POST", "arvados/v1/collections", nil, map[string]interface{}{"collection": map[string]interface{}{"manifest_text": ". d3b07384d113edec49eaa6238ad5ff00+4 0:4:foo\n"}})
+	err = arv.RequestAndDecode(&c1, "POST", "arvados/v1/collections", nil, map[string]interface{}{"collection": map[string]interface{}{"manifest_text": ". d3b07384d113edec49eaa6238ad5ff00+4 0:4:foo\n"}})
 	c.Assert(err, check.Equals, nil)
 
 	var c2 arvados.Collection
diff --git a/lib/dispatchcloud/container/queue_test.go b/lib/dispatchcloud/container/queue_test.go
index 0075ee324..fde8129f6 100644
--- a/lib/dispatchcloud/container/queue_test.go
+++ b/lib/dispatchcloud/container/queue_test.go
@@ -35,7 +35,9 @@ func logger() logrus.FieldLogger {
 type IntegrationSuite struct{}
 
 func (suite *IntegrationSuite) TearDownTest(c *check.C) {
-	err := arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil)
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	err = client.RequestAndDecode(nil, "POST", "database/reset", nil, nil)
 	c.Check(err, check.IsNil)
 }
 
@@ -44,10 +46,11 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) {
 		return arvados.InstanceType{Name: "testType"}, nil
 	}
 
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
 	cq := NewQueue(logger(), nil, typeChooser, client)
 
-	err := cq.Update()
+	err = cq.Update()
 	c.Check(err, check.IsNil)
 
 	ents, threshold := cq.Entries()
@@ -116,7 +119,8 @@ func (suite *IntegrationSuite) TestCancelIfNoInstanceType(c *check.C) {
 		return arvados.InstanceType{}, errors.New("no suitable instance type")
 	}
 
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
 	cq := NewQueue(logger(), nil, errorTypeChooser, client)
 
 	ch := cq.Subscribe()
@@ -137,7 +141,7 @@ func (suite *IntegrationSuite) TestCancelIfNoInstanceType(c *check.C) {
 	}()
 
 	var ctr arvados.Container
-	err := client.RequestAndDecode(&ctr, "GET", "arvados/v1/containers/"+arvadostest.QueuedContainerUUID, nil, nil)
+	err = client.RequestAndDecode(&ctr, "GET", "arvados/v1/containers/"+arvadostest.QueuedContainerUUID, nil, nil)
 	c.Check(err, check.IsNil)
 	c.Check(ctr.State, check.Equals, arvados.ContainerStateQueued)
 
diff --git a/lib/dispatchcloud/worker/pool_test.go b/lib/dispatchcloud/worker/pool_test.go
index 0f5c5ee19..1f0eccf56 100644
--- a/lib/dispatchcloud/worker/pool_test.go
+++ b/lib/dispatchcloud/worker/pool_test.go
@@ -96,7 +96,9 @@ func (suite *PoolSuite) TestResumeAfterRestart(c *check.C) {
 		},
 	}
 
-	pool := NewPool(logger, arvados.NewClientFromEnv(), prometheus.NewRegistry(), instanceSetID, is, newExecutor, nil, cluster)
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	pool := NewPool(logger, client, prometheus.NewRegistry(), instanceSetID, is, newExecutor, nil, cluster)
 	notify := pool.Subscribe()
 	defer pool.Unsubscribe(notify)
 	pool.Create(type1)
@@ -131,8 +133,9 @@ func (suite *PoolSuite) TestResumeAfterRestart(c *check.C) {
 	pool.Stop()
 
 	c.Log("------- starting new pool, waiting to recover state")
-
-	pool2 := NewPool(logger, arvados.NewClientFromEnv(), prometheus.NewRegistry(), instanceSetID, is, newExecutor, nil, cluster)
+	client, err = arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	pool2 := NewPool(logger, client, prometheus.NewRegistry(), instanceSetID, is, newExecutor, nil, cluster)
 	notify2 := pool2.Subscribe()
 	defer pool2.Unsubscribe(notify2)
 	waitForIdle(pool2, notify2)
@@ -153,8 +156,8 @@ func (suite *PoolSuite) TestDrain(c *check.C) {
 	instanceSet, err := driver.InstanceSet(nil, "test-instance-set-id", nil, logger)
 	c.Assert(err, check.IsNil)
 
-	ac := arvados.NewClientFromEnv()
-
+	ac, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	type1 := test.InstanceType(1)
 	pool := &Pool{
 		arvClient:   ac,
diff --git a/lib/dispatchcloud/worker/worker_test.go b/lib/dispatchcloud/worker/worker_test.go
index 4134788b2..09fa8f8a9 100644
--- a/lib/dispatchcloud/worker/worker_test.go
+++ b/lib/dispatchcloud/worker/worker_test.go
@@ -30,7 +30,8 @@ func (suite *WorkerSuite) TestProbeAndUpdate(c *check.C) {
 	bootTimeout := time.Minute
 	probeTimeout := time.Second
 
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	is, err := (&test.StubDriver{}).InstanceSet(nil, "test-instance-set-id", nil, logger)
 	c.Assert(err, check.IsNil)
 	inst, err := is.Create(arvados.InstanceType{}, "", nil, "echo InitCommand", nil)
diff --git a/lib/mount/command.go b/lib/mount/command.go
index e92af2407..c5e404de9 100644
--- a/lib/mount/command.go
+++ b/lib/mount/command.go
@@ -9,6 +9,7 @@ import (
 	"io"
 	"log"
 	"net/http"
+
 	// pprof is only imported to register its HTTP handlers
 	_ "net/http/pprof"
 	"os"
@@ -58,7 +59,11 @@ func (c *cmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, st
 		}()
 	}
 
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	if err != nil {
+		logger.Print(err)
+		return 1
+	}
 	ac, err := arvadosclient.New(client)
 	if err != nil {
 		logger.Print(err)
diff --git a/lib/mount/fs_test.go b/lib/mount/fs_test.go
index fef2c0f06..d5b04592a 100644
--- a/lib/mount/fs_test.go
+++ b/lib/mount/fs_test.go
@@ -28,7 +28,8 @@ func (*FSSuite) TestFuseInterface(c *check.C) {
 }
 
 func (*FSSuite) TestOpendir(c *check.C) {
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	ac, err := arvadosclient.New(client)
 	c.Assert(err, check.IsNil)
 	kc, err := keepclient.MakeKeepClient(ac)
diff --git a/sdk/go/arvados/client.go b/sdk/go/arvados/client.go
index 13bb3bf80..7e6d60397 100644
--- a/sdk/go/arvados/client.go
+++ b/sdk/go/arvados/client.go
@@ -104,7 +104,7 @@ func NewClientFromConfig(cluster *Cluster) (*Client, error) {
 // NewClientFromEnv creates a new Client that uses the default HTTP
 // client with the API endpoint and credentials given by the
 // ARVADOS_API_* environment variables.
-func NewClientFromEnv() *Client {
+func NewClientFromEnv() (*Client, error) {
 	var svcs []string
 	for _, s := range strings.Split(os.Getenv("ARVADOS_KEEP_SERVICES"), " ") {
 		if s == "" {
@@ -121,6 +121,7 @@ func NewClientFromEnv() *Client {
 	if s := strings.ToLower(os.Getenv("ARVADOS_API_HOST_INSECURE")); s == "1" || s == "yes" || s == "true" {
 		insecure = true
 	}
+
 	return &Client{
 		Scheme:          "https",
 		APIHost:         os.Getenv("ARVADOS_API_HOST"),
@@ -129,7 +130,7 @@ func NewClientFromEnv() *Client {
 		KeepServiceURIs: svcs,
 		Timeout:         5 * time.Minute,
 		loadedFromEnv:   true,
-	}
+	}, nil
 }
 
 var reqIDGen = httpserver.IDGenerator{Prefix: "req-"}
diff --git a/sdk/go/arvados/fs_collection_test.go b/sdk/go/arvados/fs_collection_test.go
index 05c8ea61a..a8e85aa41 100644
--- a/sdk/go/arvados/fs_collection_test.go
+++ b/sdk/go/arvados/fs_collection_test.go
@@ -92,7 +92,11 @@ type CollectionFSSuite struct {
 }
 
 func (s *CollectionFSSuite) SetUpTest(c *check.C) {
-	s.client = NewClientFromEnv()
+
+	var clientErr error
+	s.client, clientErr = NewClientFromEnv()
+	c.Assert(clientErr, check.IsNil)
+
 	err := s.client.RequestAndDecode(&s.coll, "GET", "arvados/v1/collections/"+fixtureFooAndBarFilesInDirUUID, nil, nil)
 	c.Assert(err, check.IsNil)
 	s.kc = &keepClientStub{
diff --git a/sdk/go/arvadosclient/arvadosclient.go b/sdk/go/arvadosclient/arvadosclient.go
index d90c618f7..4dfb24108 100644
--- a/sdk/go/arvadosclient/arvadosclient.go
+++ b/sdk/go/arvadosclient/arvadosclient.go
@@ -191,7 +191,11 @@ func New(c *arvados.Client) (*ArvadosClient, error) {
 // ARVADOS_API_HOST_INSECURE, ARVADOS_EXTERNAL_CLIENT, and
 // ARVADOS_KEEP_SERVICES.
 func MakeArvadosClient() (ac *ArvadosClient, err error) {
-	ac, err = New(arvados.NewClientFromEnv())
+	c, err := arvados.NewClientFromEnv()
+	if err != nil {
+		return
+	}
+	ac, err = New(c)
 	if err != nil {
 		return
 	}
diff --git a/services/keep-web/cadaver_test.go b/services/keep-web/cadaver_test.go
index e965a6e8c..5a4802c8d 100644
--- a/services/keep-web/cadaver_test.go
+++ b/services/keep-web/cadaver_test.go
@@ -71,7 +71,8 @@ func (s *IntegrationSuite) testCadaver(c *check.C, password string, pathFunc fun
 	c.Assert(err, check.IsNil)
 
 	var newCollection arvados.Collection
-	arv := arvados.NewClientFromEnv()
+	arv, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	arv.AuthToken = arvadostest.ActiveToken
 	err = arv.RequestAndDecode(&newCollection, "POST", "arvados/v1/collections", nil, map[string]interface{}{"collection": map[string]interface{}{}})
 	c.Assert(err, check.IsNil)
diff --git a/services/keep-web/handler_test.go b/services/keep-web/handler_test.go
index 5291efeb8..275a98474 100644
--- a/services/keep-web/handler_test.go
+++ b/services/keep-web/handler_test.go
@@ -508,7 +508,8 @@ func (s *IntegrationSuite) TestSpecialCharsInPath(c *check.C) {
 }
 
 func (s *IntegrationSuite) TestForwardSlashSubstitution(c *check.C) {
-	arv := arvados.NewClientFromEnv()
+	arv, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	s.testServer.Config.cluster.Services.WebDAVDownload.ExternalURL.Host = "download.example.com"
 	s.testServer.Config.cluster.Collections.ForwardSlashNameSubstitution = "{SOLIDUS}"
 	name := "foo/bar/baz"
@@ -879,9 +880,10 @@ func (s *IntegrationSuite) testDirectoryListing(c *check.C) {
 }
 
 func (s *IntegrationSuite) TestDeleteLastFile(c *check.C) {
-	arv := arvados.NewClientFromEnv()
+	arv, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	var newCollection arvados.Collection
-	err := arv.RequestAndDecode(&newCollection, "POST", "arvados/v1/collections", nil, map[string]interface{}{
+	err = arv.RequestAndDecode(&newCollection, "POST", "arvados/v1/collections", nil, map[string]interface{}{
 		"collection": map[string]string{
 			"owner_uuid":    arvadostest.ActiveUserUUID,
 			"manifest_text": ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo.txt 0:3:bar.txt\n",
diff --git a/services/keep-web/s3_test.go b/services/keep-web/s3_test.go
index e60b55c93..a58c48ded 100644
--- a/services/keep-web/s3_test.go
+++ b/services/keep-web/s3_test.go
@@ -41,9 +41,10 @@ type s3stage struct {
 func (s *IntegrationSuite) s3setup(c *check.C) s3stage {
 	var proj arvados.Group
 	var coll arvados.Collection
-	arv := arvados.NewClientFromEnv()
+	arv, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	arv.AuthToken = arvadostest.ActiveToken
-	err := arv.RequestAndDecode(&proj, "POST", "arvados/v1/groups", nil, map[string]interface{}{
+	err = arv.RequestAndDecode(&proj, "POST", "arvados/v1/groups", nil, map[string]interface{}{
 		"group": map[string]interface{}{
 			"group_class": "project",
 			"name":        "keep-web s3 test",
diff --git a/services/keepproxy/keepproxy_test.go b/services/keepproxy/keepproxy_test.go
index 6a02ab9bd..d57a57bbb 100644
--- a/services/keepproxy/keepproxy_test.go
+++ b/services/keepproxy/keepproxy_test.go
@@ -140,7 +140,8 @@ func runProxy(c *C, bogusClientToken bool, loadKeepstoresFromConfig bool) *keepc
 	}()
 	waitForListener()
 
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	c.Assert(err, Equals, nil)
 	arv, err := arvadosclient.New(client)
 	c.Assert(err, Equals, nil)
 	if bogusClientToken {
diff --git a/services/ws/permission_test.go b/services/ws/permission_test.go
index 023656c01..5895aa624 100644
--- a/services/ws/permission_test.go
+++ b/services/ws/permission_test.go
@@ -17,7 +17,9 @@ var _ = check.Suite(&permSuite{})
 type permSuite struct{}
 
 func (s *permSuite) TestCheck(c *check.C) {
-	pc := newPermChecker(*(arvados.NewClientFromEnv())).(*cachingPermChecker)
+	client, err := arvados.NewClientFromEnv()
+	c.Check(err, check.IsNil)
+	pc := newPermChecker(*(client)).(*cachingPermChecker)
 	setToken := func(label, token string) {
 		c.Logf("...%s token %q", label, token)
 		pc.SetToken(token)
diff --git a/services/ws/service_test.go b/services/ws/service_test.go
index 4e68d09da..e1cd459ae 100644
--- a/services/ws/service_test.go
+++ b/services/ws/service_test.go
@@ -66,7 +66,10 @@ func (*serviceSuite) testConfig(c *check.C) (*arvados.Cluster, error) {
 	if err != nil {
 		return nil, err
 	}
-	client := arvados.NewClientFromEnv()
+	client, err := arvados.NewClientFromEnv()
+	if err != nil {
+		return nil, err
+	}
 	cluster.Services.Controller.ExternalURL.Host = client.APIHost
 	cluster.SystemRootToken = client.AuthToken
 	cluster.TLS.Insecure = client.Insecure
diff --git a/services/ws/session_v0_test.go b/services/ws/session_v0_test.go
index 7986cc7b0..c80010d4a 100644
--- a/services/ws/session_v0_test.go
+++ b/services/ws/session_v0_test.go
@@ -56,7 +56,10 @@ func (s *v0Suite) TearDownSuite(c *check.C) {
 }
 
 func (s *v0Suite) deleteTestObjects(c *check.C) {
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	if err != nil {
+		panic(err)
+	}
 	ac.AuthToken = arvadostest.AdminToken
 	for _, path := range s.toDelete {
 		err := ac.RequestAndDecode(nil, "DELETE", path, nil, nil)
@@ -205,11 +208,12 @@ func (s *v0Suite) TestEventTypeDelete(c *check.C) {
 // Trashing/deleting a collection produces an "update" event with
 // properties["new_attributes"]["is_trashed"] == true.
 func (s *v0Suite) TestTrashedCollection(c *check.C) {
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	c.Assert(err, check.IsNil)
 	ac.AuthToken = s.token
 
 	var coll arvados.Collection
-	err := ac.RequestAndDecode(&coll, "POST", "arvados/v1/collections", s.jsonBody("collection", `{"manifest_text":""}`), map[string]interface{}{"ensure_unique_name": true})
+	err = ac.RequestAndDecode(&coll, "POST", "arvados/v1/collections", s.jsonBody("collection", `{"manifest_text":""}`), map[string]interface{}{"ensure_unique_name": true})
 	c.Assert(err, check.IsNil)
 	s.ignoreLogID = s.lastLogID(c)
 
@@ -285,12 +289,15 @@ func (s *v0Suite) emitEvents(uuidChan chan<- string) {
 	s.wg.Add(1)
 	defer s.wg.Done()
 
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	if err != nil {
+		panic(err)
+	}
 	ac.AuthToken = s.token
 	wf := &arvados.Workflow{
 		Name: "ws_test",
 	}
-	err := ac.RequestAndDecode(wf, "POST", "arvados/v1/workflows", s.jsonBody("workflow", `{"name":"ws_test"}`), map[string]interface{}{"ensure_unique_name": true})
+	err = ac.RequestAndDecode(wf, "POST", "arvados/v1/workflows", s.jsonBody("workflow", `{"name":"ws_test"}`), map[string]interface{}{"ensure_unique_name": true})
 	if err != nil {
 		panic(err)
 	}
diff --git a/tools/sync-groups/sync-groups.go b/tools/sync-groups/sync-groups.go
index 24e838c8f..6418d9ecf 100644
--- a/tools/sync-groups/sync-groups.go
+++ b/tools/sync-groups/sync-groups.go
@@ -265,8 +265,12 @@ func GetConfig() (config ConfigParams, err error) {
 	}
 
 	// Arvados Client setup
-	config.Client = arvados.NewClientFromEnv()
+	var clientErr error
+	config.Client, clientErr = arvados.NewClientFromEnv()
 
+	if clientErr != nil {
+		return config, fmt.Errorf("error getting configuration from environment: %s", err)
+	}
 	// Check current user permissions & get System user's UUID
 	u, err := config.Client.CurrentUser()
 	if err != nil {
diff --git a/tools/sync-groups/sync-groups_test.go b/tools/sync-groups/sync-groups_test.go
index ec2f18a30..fecd60995 100644
--- a/tools/sync-groups/sync-groups_test.go
+++ b/tools/sync-groups/sync-groups_test.go
@@ -27,7 +27,8 @@ type TestSuite struct {
 }
 
 func (s *TestSuite) SetUpTest(c *C) {
-	ac := arvados.NewClientFromEnv()
+	ac, err := arvados.NewClientFromEnv()
+	c.Assert(err, IsNil)
 	u, err := ac.CurrentUser()
 	c.Assert(err, IsNil)
 	// Check that the parent group doesn't exist

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list