X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b17b1ad22bd3cf518eb1b3657f62768b60c7db25..c3d4f8a585202ec58df5506934b698039c200b68:/sdk/go/keepclient/discover.go?ds=sidebyside diff --git a/sdk/go/keepclient/discover.go b/sdk/go/keepclient/discover.go index 099c56f343..2892031817 100644 --- a/sdk/go/keepclient/discover.go +++ b/sdk/go/keepclient/discover.go @@ -12,16 +12,32 @@ 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 { - var list svcList + 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 + } + this.SetServiceRoots(roots, roots, roots) + return nil + } - // Get keep services from api server + // ArvadosClient did not provide a services list. Ask API + // server for a list of accessible services. + var list svcList err := this.Arvados.Call("GET", "keep_services", "", "accessible", nil, &list) if err != nil { return err } - return this.loadKeepServers(list) } @@ -57,14 +73,14 @@ func (kc *KeepClient) RefreshServices(interval, errInterval time.Duration) { timer.Reset(interval) if err := kc.DiscoverKeepServers(); err != nil { - log.Println("Error retrieving services list: %v (retrying in %v)", err, errInterval) + log.Printf("WARNING: Error retrieving services list: %v (retrying in %v)", err, errInterval) timer.Reset(errInterval) continue } newRoots := []map[string]string{kc.LocalRoots(), kc.GatewayRoots()} if !reflect.DeepEqual(previousRoots, newRoots) { - log.Printf("Updated services list: locals %v gateways %v", newRoots[0], newRoots[1]) + DebugPrintf("DEBUG: Updated services list: locals %v gateways %v", newRoots[0], newRoots[1]) previousRoots = newRoots }