[arvados] updated: 2.7.0-5392-g9f48c431a8
git repository hosting
git at public.arvados.org
Mon Nov 27 17:31:05 UTC 2023
Summary of changes:
lib/controller/federation/conn.go | 4 ++--
lib/controller/rpc/conn.go | 7 ++++++-
2 files changed, 8 insertions(+), 3 deletions(-)
via 9f48c431a829cfa26e2a20ab306b37613d445fa1 (commit)
from 2c0bf8219eb3ff5f978d147bff7ae6c6a73e8188 (commit)
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 9f48c431a829cfa26e2a20ab306b37613d445fa1
Author: Peter Amstutz <peter.amstutz at curii.com>
Date: Mon Nov 27 12:29:28 2023 -0500
20831: DiscoveryDocument fn improvements
* Only cache discovery document for 1 hour
* rpc.Conn takes a mutex when working with discovery document
* Simplify a couple of cases where calling chooseBackend would always return conn.local
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>
diff --git a/lib/controller/federation/conn.go b/lib/controller/federation/conn.go
index 75b9f2136b..c5facdc7d9 100644
--- a/lib/controller/federation/conn.go
+++ b/lib/controller/federation/conn.go
@@ -225,11 +225,11 @@ func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
}
func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error) {
- return conn.chooseBackend(conn.cluster.ClusterID).VocabularyGet(ctx)
+ return conn.local.VocabularyGet(ctx)
}
func (conn *Conn) DiscoveryDocument(ctx context.Context) (arvados.DiscoveryDocument, error) {
- return conn.chooseBackend(conn.cluster.ClusterID).DiscoveryDocument(ctx)
+ return conn.local.DiscoveryDocument(ctx)
}
func (conn *Conn) Login(ctx context.Context, options arvados.LoginOptions) (arvados.LoginResponse, error) {
diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go
index 6195b79da1..5d1b0e52fe 100644
--- a/lib/controller/rpc/conn.go
+++ b/lib/controller/rpc/conn.go
@@ -49,6 +49,8 @@ type Conn struct {
baseURL url.URL
tokenProvider TokenProvider
discoveryDocument *arvados.DiscoveryDocument
+ discoveryDocumentMtx sync.Mutex
+ discoveryDocumentExpires time.Time
}
func NewConn(clusterID string, url *url.URL, insecure bool, tp TokenProvider) *Conn {
@@ -194,7 +196,9 @@ func (conn *Conn) VocabularyGet(ctx context.Context) (arvados.Vocabulary, error)
}
func (conn *Conn) DiscoveryDocument(ctx context.Context) (arvados.DiscoveryDocument, error) {
- if conn.discoveryDocument != nil {
+ conn.discoveryDocumentMtx.Lock()
+ defer conn.discoveryDocumentMtx.Unlock()
+ if conn.discoveryDocument != nil && time.Now().Before(conn.discoveryDocumentExpires) {
return *conn.discoveryDocument, nil
}
var dd arvados.DiscoveryDocument
@@ -203,6 +207,7 @@ func (conn *Conn) DiscoveryDocument(ctx context.Context) (arvados.DiscoveryDocum
return dd, err
}
conn.discoveryDocument = &dd
+ discoveryDocumentExpires = time.Now().Add(time.Hour)
return *conn.discoveryDocument, nil
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list