[ARVADOS] created: 6e97eab637af4680baf4686310f80cecc062196c

Git user git at public.curoverse.com
Fri Jun 24 21:58:00 EDT 2016


        at  6e97eab637af4680baf4686310f80cecc062196c (commit)


commit 6e97eab637af4680baf4686310f80cecc062196c
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Jun 24 21:57:30 2016 -0400

    9491: Fix keepproxy support for X-Keep-Desired-Replicas header.

diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index 4cd9310..df7528e 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -424,7 +424,7 @@ func (this PutBlockHandler) ServeHTTP(resp http.ResponseWriter, req *http.Reques
 	if req.Header.Get("X-Keep-Desired-Replicas") != "" {
 		var r int
 		_, err := fmt.Sscanf(req.Header.Get(keepclient.X_Keep_Desired_Replicas), "%d", &r)
-		if err != nil {
+		if err == nil {
 			kc.Want_replicas = r
 		}
 	}
diff --git a/services/keepproxy/keepproxy_test.go b/services/keepproxy/keepproxy_test.go
index 4a1d58f..a3ca5f1 100644
--- a/services/keepproxy/keepproxy_test.go
+++ b/services/keepproxy/keepproxy_test.go
@@ -109,6 +109,23 @@ func runProxy(c *C, args []string, bogusClientToken bool) *keepclient.KeepClient
 	return kc
 }
 
+func (s *ServerRequiredSuite) TestDesiredReplicas(c *C) {
+	kc := runProxy(c, nil, false)
+	defer closeListener()
+
+	content := []byte("TestDesiredReplicas")
+	hash := fmt.Sprintf("%x", md5.Sum(content))
+
+	for _, kc.Want_replicas = range []int{0, 1, 2} {
+		locator, rep, err := kc.PutB(content)
+		c.Check(err, Equals, nil)
+		c.Check(rep, Equals, kc.Want_replicas)
+		if rep > 0 {
+			c.Check(locator, Matches, fmt.Sprintf(`^%s\+%d(\+.+)?$`, hash, len(content)))
+		}
+	}
+}
+
 func (s *ServerRequiredSuite) TestPutAskGet(c *C) {
 	kc := runProxy(c, nil, false)
 	defer closeListener()

commit bcbf807454e8957ab5653aa4d3e6ea686f5482fb
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Jun 24 21:55:16 2016 -0400

    9491: Put*() return number of replicas actually stored, even if we ended up storing more than requested.

diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index b12f512..2244779 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -184,13 +184,13 @@ func (this *KeepClient) putReplicas(
 		}()
 	}()
 
-	// Desired number of replicas
-	remaining_replicas := this.Want_replicas
+	replicasDone := 0
+	replicasTodo := this.Want_replicas
 
 	replicasPerThread := this.replicasPerService
 	if replicasPerThread < 1 {
 		// unlimited or unknown
-		replicasPerThread = remaining_replicas
+		replicasPerThread = replicasTodo
 	}
 
 	retriesRemaining := 1 + this.Retries
@@ -200,8 +200,8 @@ func (this *KeepClient) putReplicas(
 		retriesRemaining -= 1
 		next_server = 0
 		retryServers = []string{}
-		for remaining_replicas > 0 {
-			for active*replicasPerThread < remaining_replicas {
+		for replicasTodo > 0 {
+			for active*replicasPerThread < replicasTodo {
 				// Start some upload requests
 				if next_server < len(sv) {
 					DebugPrintf("DEBUG: [%08x] Begin upload %s to %s", requestID, hash, sv[next_server])
@@ -210,14 +210,14 @@ func (this *KeepClient) putReplicas(
 					active += 1
 				} else {
 					if active == 0 && retriesRemaining == 0 {
-						return locator, (this.Want_replicas - remaining_replicas), InsufficientReplicasError
+						return locator, replicasDone, InsufficientReplicasError
 					} else {
 						break
 					}
 				}
 			}
 			DebugPrintf("DEBUG: [%08x] Replicas remaining to write: %v active uploads: %v",
-				requestID, remaining_replicas, active)
+				requestID, replicasTodo, active)
 
 			// Now wait for something to happen.
 			if active > 0 {
@@ -226,7 +226,8 @@ func (this *KeepClient) putReplicas(
 
 				if status.statusCode == 200 {
 					// good news!
-					remaining_replicas -= status.replicas_stored
+					replicasDone += status.replicas_stored
+					replicasTodo -= status.replicas_stored
 					locator = status.response
 				} else if status.statusCode == 0 || status.statusCode == 408 || status.statusCode == 429 ||
 					(status.statusCode >= 500 && status.statusCode != 503) {
@@ -242,5 +243,5 @@ func (this *KeepClient) putReplicas(
 		sv = retryServers
 	}
 
-	return locator, this.Want_replicas, nil
+	return locator, replicasDone, nil
 }

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list