10383: Merge branch 'master' into 10383-arv-put-incremental-upload
[arvados.git] / sdk / go / keepclient / keepclient.go
index 0e6fadcc3548c99d2e85c30219a74ffdce42bf72..79a87156a6cd829a87cd77a2ba357ce1484a4cdc 100644 (file)
@@ -4,14 +4,12 @@ package keepclient
 import (
        "bytes"
        "crypto/md5"
-       "crypto/tls"
        "errors"
        "fmt"
        "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
        "git.curoverse.com/arvados.git/sdk/go/streamer"
        "io"
        "io/ioutil"
-       "log"
        "net/http"
        "regexp"
        "strconv"
@@ -68,7 +66,6 @@ const X_Keep_Replicas_Stored = "X-Keep-Replicas-Stored"
 type KeepClient struct {
        Arvados            *arvadosclient.ArvadosClient
        Want_replicas      int
-       Using_proxy        bool
        localRoots         *map[string]string
        writableLocalRoots *map[string]string
        gatewayRoots       *map[string]string
@@ -78,6 +75,9 @@ type KeepClient struct {
 
        // set to 1 if all writable services are of disk type, otherwise 0
        replicasPerService int
+
+       // Any non-disk typed services found in the list of keepservers?
+       foundNonDiskSvc bool
 }
 
 // MakeKeepClient creates a new KeepClient by contacting the API server to discover Keep servers.
@@ -101,9 +101,8 @@ func New(arv *arvadosclient.ArvadosClient) *KeepClient {
        kc := &KeepClient{
                Arvados:       arv,
                Want_replicas: defaultReplicationLevel,
-               Using_proxy:   false,
                Client: &http.Client{Transport: &http.Transport{
-                       TLSClientConfig: &tls.Config{InsecureSkipVerify: arv.ApiInsecure}}},
+                       TLSClientConfig: arvadosclient.MakeTLSConfig(arv.ApiInsecure)}},
                Retries: 2,
        }
        return kc
@@ -232,7 +231,7 @@ func (kc *KeepClient) getOrHead(method string, locator string) (io.ReadCloser, i
                }
                serversToTry = retryList
        }
-       log.Printf("DEBUG: %s %s failed: %v", method, locator, errs)
+       DebugPrintf("DEBUG: %s %s failed: %v", method, locator, errs)
 
        var err error
        if count404 == numServers {
@@ -352,7 +351,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