[ARVADOS] updated: af57f2401366e9d67627b93b12d2096d771a9985

Git user git at public.curoverse.com
Fri Jul 22 09:43:10 EDT 2016


Summary of changes:
 .../test/integration/user_profile_test.rb          | 132 ++++++++++-----------
 1 file changed, 62 insertions(+), 70 deletions(-)

  discards  2963b7352362d0e50bfcd9f59424ca5aae70a2fd (commit)
       via  af57f2401366e9d67627b93b12d2096d771a9985 (commit)
       via  34f8647caace707dfb524a89d27bded9274058fb (commit)
       via  23f489fc31a5afbcab22e2c5c0a80afa232b4ee2 (commit)
       via  de243dc7677355e4d2045fd47495788125e883d1 (commit)
       via  78a0505d03f79f667926eff41954f5212bf57c2c (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (2963b7352362d0e50bfcd9f59424ca5aae70a2fd)
            \
             N -- N -- N (af57f2401366e9d67627b93b12d2096d771a9985)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit af57f2401366e9d67627b93b12d2096d771a9985
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Jul 22 09:41:47 2016 -0400

    9550: Allow overriding keep services discovery with ARVADOS_KEEP_SERVICES env var.

diff --git a/sdk/go/arvadosclient/arvadosclient.go b/sdk/go/arvadosclient/arvadosclient.go
index 8cdfa48..2befcd5 100644
--- a/sdk/go/arvadosclient/arvadosclient.go
+++ b/sdk/go/arvadosclient/arvadosclient.go
@@ -86,6 +86,10 @@ type ArvadosClient struct {
 	// the client is outside the cluster.
 	External bool
 
+	// Use provided list of keep services, instead of using the
+	// API to discover available services.
+	KeepServiceURIs []string
+
 	// Discovery document
 	DiscoveryDoc Dict
 
@@ -113,6 +117,10 @@ func MakeArvadosClient() (ac ArvadosClient, err error) {
 		External: external,
 		Retries:  2}
 
+	if s := os.Getenv("ARVADOS_KEEP_SERVICES"); s != "" {
+		ac.KeepServiceURIs = strings.Split(s, " ")
+	}
+
 	if ac.ApiServer == "" {
 		return ac, MissingArvadosApiHost
 	}
diff --git a/sdk/go/keepclient/discover.go b/sdk/go/keepclient/discover.go
index f039c21..9cf920c 100644
--- a/sdk/go/keepclient/discover.go
+++ b/sdk/go/keepclient/discover.go
@@ -12,8 +12,26 @@ import (
 	"time"
 )
 
-// DiscoverKeepServers gets list of available keep services from api server
+// DiscoverKeepServers gets list of available keep services from the
+// API server.
+//
+// If a list of services is provided in the arvadosclient (e.g., from
+// an environment variable or local config), that list is used
+// instead.
 func (this *KeepClient) DiscoverKeepServers() error {
+	if this.Arvados.KeepServiceURIs != nil {
+		this.foundNonDiskSvc = true
+		this.replicasPerService = 0
+		this.setClientSettingsNonDisk()
+		roots := make(map[string]string)
+		for i, uri := range this.Arvados.KeepServiceURIs {
+			roots[fmt.Sprintf("00000-bi6l4-%015d", i)] = uri
+		}
+		log.Printf("%+v", roots)
+		this.SetServiceRoots(roots, roots, roots)
+		return nil
+	}
+
 	var list svcList
 
 	// Get keep services from api server
diff --git a/sdk/go/keepclient/discover_test.go b/sdk/go/keepclient/discover_test.go
index 43a984e..ab7b2da 100644
--- a/sdk/go/keepclient/discover_test.go
+++ b/sdk/go/keepclient/discover_test.go
@@ -1,10 +1,15 @@
 package keepclient
 
 import (
+	"crypto/md5"
 	"fmt"
+	"gopkg.in/check.v1"
+	"net/http"
+	"os"
 	"time"
 
 	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"git.curoverse.com/arvados.git/sdk/go/arvadostest"
 )
 
 func ExampleRefreshServices() {
@@ -19,3 +24,42 @@ func ExampleRefreshServices() {
 	go kc.RefreshServices(5*time.Minute, 3*time.Second)
 	fmt.Printf("LocalRoots: %#v\n", kc.LocalRoots())
 }
+
+func (s *ServerRequiredSuite) TestOverrideDiscovery(c *check.C) {
+	defer os.Setenv("ARVADOS_KEEP_SERVICES", "")
+
+	hash := fmt.Sprintf("%x+3", md5.Sum([]byte("TestOverrideDiscovery")))
+	st := StubGetHandler{
+		c,
+		hash,
+		arvadostest.ActiveToken,
+		http.StatusOK,
+		[]byte("TestOverrideDiscovery")}
+	ks := RunSomeFakeKeepServers(st, 2)
+
+	os.Setenv("ARVADOS_KEEP_SERVICES", "")
+	arv1, err := arvadosclient.MakeArvadosClient()
+	c.Assert(err, check.IsNil)
+	arv1.ApiToken = arvadostest.ActiveToken
+
+	os.Setenv("ARVADOS_KEEP_SERVICES", ks[0].url+" "+ks[1].url)
+	arv2, err := arvadosclient.MakeArvadosClient()
+	c.Assert(err, check.IsNil)
+	arv2.ApiToken = arvadostest.ActiveToken
+
+	// ARVADOS_KEEP_SERVICES was empty when we created arv1, but
+	// it pointed to our stub servers when we created
+	// arv2. Regardless of what it's set to now, a keepclient for
+	// arv2 should use our stub servers, but one created for arv1
+	// should not.
+
+	kc1, err := MakeKeepClient(&arv1)
+	c.Assert(err, check.IsNil)
+	kc2, err := MakeKeepClient(&arv2)
+	c.Assert(err, check.IsNil)
+
+	_, _, _, err = kc1.Get(hash)
+	c.Check(err, check.NotNil)
+	_, _, _, err = kc2.Get(hash)
+	c.Check(err, check.IsNil)
+}
diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index 26aa717..58f3ffb 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -352,7 +352,7 @@ func (kc *KeepClient) WritableLocalRoots() map[string]string {
 // caller can reuse/modify them after SetServiceRoots returns, but
 // they should not be modified by any other goroutine while
 // SetServiceRoots is running.
-func (kc *KeepClient) SetServiceRoots(newLocals, newWritableLocals map[string]string, newGateways map[string]string) {
+func (kc *KeepClient) SetServiceRoots(newLocals, newWritableLocals, newGateways map[string]string) {
 	locals := make(map[string]string)
 	for uuid, root := range newLocals {
 		locals[uuid] = root

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list