[ARVADOS] updated: 3596b89edfbea42ce52d6c7112e4e18797895423

git at public.curoverse.com git at public.curoverse.com
Fri Oct 9 15:03:12 EDT 2015


Summary of changes:
 sdk/go/keepclient/keepclient.go | 58 ++++++++++++++++++++---------------------
 sdk/go/keepclient/support.go    | 12 ++++++++-
 2 files changed, 39 insertions(+), 31 deletions(-)

       via  3596b89edfbea42ce52d6c7112e4e18797895423 (commit)
       via  8d4e8098591e5545a66670e60911599d5e0903ac (commit)
      from  d3c7b9502d9297d71225ebdbb81616f7613348b5 (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 3596b89edfbea42ce52d6c7112e4e18797895423
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri Oct 9 15:05:10 2015 -0400

    7491: Go through entire server list instead of immediately retrying on error.
    Only retry servers that resulted in an error (network or HTTP 5xx error).

diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index 8272d11..2cf852b 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -149,13 +149,18 @@ func (kc *KeepClient) PutR(r io.Reader) (locator string, replicas int, err error
 // instead of EOF.
 func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error) {
 	var errs []string
-	server_error := false
 
-	for _, host := range kc.getSortedRoots(locator) {
-		url := host + "/" + locator
-		tries_remaining := 1 + kc.Retries
-		for tries_remaining > 0 {
-			tries_remaining -= 1
+	tries_remaining := 1 + kc.Retries
+	serversToTry := kc.getSortedRoots(locator)
+	var retryList []string
+
+	for tries_remaining > 0 {
+		tries_remaining -= 1
+		retryList = nil
+
+		for _, host := range serversToTry {
+			url := host + "/" + locator
+
 			req, err := http.NewRequest("GET", url, nil)
 			if err != nil {
 				errs = append(errs, fmt.Sprintf("%s: %v", url, err))
@@ -164,10 +169,10 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
 			req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", kc.Arvados.ApiToken))
 			resp, err := kc.Client.Do(req)
 			if err != nil {
-				// Probably a network error, may be
-				// transient, can try again.
-				server_error = true
+				// Probably a network error, may be transient,
+				// can try again.
 				errs = append(errs, fmt.Sprintf("%s: %v", url, err))
+				retryList = append(retryList, host)
 			} else if resp.StatusCode != http.StatusOK {
 				respbody, _ := ioutil.ReadAll(&io.LimitedReader{resp.Body, 4096})
 				resp.Body.Close()
@@ -177,12 +182,7 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
 				if resp.StatusCode >= 500 {
 					// Server side failure, may be
 					// transient, can try again.
-					server_error = true
-				} else {
-					// Some other error (4xx),
-					// typically 403 or 404, don't
-					// try again.
-					tries_remaining = 0
+					retryList = append(retryList, host)
 				}
 			} else {
 				// Success.
@@ -193,10 +193,11 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
 				}, resp.ContentLength, url, nil
 			}
 		}
+		serversToTry = retryList
 	}
 	log.Printf("DEBUG: GET %s failed: %v", locator, errs)
 
-	if server_error {
+	if len(retryList) > 0 {
 		// There was at least one failure to get a final answer
 		return nil, 0, "", KeepServerError
 	} else {

commit 8d4e8098591e5545a66670e60911599d5e0903ac
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri Oct 9 14:50:37 2015 -0400

    7491: Manual merge with 7491-keepclient-bugs

diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index cc6efcb..8272d11 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -158,34 +158,31 @@ func (kc *KeepClient) Get(locator string) (io.ReadCloser, int64, string, error)
 			tries_remaining -= 1
 			req, err := http.NewRequest("GET", url, nil)
 			if err != nil {
+				errs = append(errs, fmt.Sprintf("%s: %v", url, err))
 				continue
 			}
 			req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", kc.Arvados.ApiToken))
 			resp, err := kc.Client.Do(req)
-			if err != nil || resp.StatusCode != http.StatusOK {
-				if resp != nil {
-					var respbody []byte
-					if resp.Body != nil {
-						respbody, _ = ioutil.ReadAll(&io.LimitedReader{resp.Body, 4096})
-					}
-					errs = append(errs, fmt.Sprintf("%s: %d %s",
-						url, resp.StatusCode, strings.TrimSpace(string(respbody))))
-
-					if resp.StatusCode >= 500 {
-						// Server side failure, may be
-						// transient, can try again.
-						server_error = true
-					} else {
-						// Some other error (4xx),
-						// typically 403 or 404, don't
-						// try again.
-						tries_remaining = 0
-					}
-				} else {
-					// Probably a network error, may be
+			if err != nil {
+				// Probably a network error, may be
+				// transient, can try again.
+				server_error = true
+				errs = append(errs, fmt.Sprintf("%s: %v", url, err))
+			} else if resp.StatusCode != http.StatusOK {
+				respbody, _ := ioutil.ReadAll(&io.LimitedReader{resp.Body, 4096})
+				resp.Body.Close()
+				errs = append(errs, fmt.Sprintf("%s: %d %s",
+					url, resp.StatusCode, bytes.TrimSpace(respbody)))
+
+				if resp.StatusCode >= 500 {
+					// Server side failure, may be
 					// transient, can try again.
 					server_error = true
-					errs = append(errs, fmt.Sprintf("%s: %v", url, err))
+				} else {
+					// Some other error (4xx),
+					// typically 403 or 404, don't
+					// try again.
+					tries_remaining = 0
 				}
 			} else {
 				// Success.
diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index 63800b1..51e3e08 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -228,7 +228,17 @@ func (this KeepClient) putReplicas(
 
 	// Used to communicate status from the upload goroutines
 	upload_status := make(chan uploadStatus)
-	defer close(upload_status)
+	defer func() {
+		// Wait for any abandoned uploads (e.g., we started
+		// two uploads and the first replied with replicas=2)
+		// to finish before closing the status channel.
+		go func() {
+			for active > 0 {
+				<-upload_status
+			}
+			close(upload_status)
+		}()
+	}()
 
 	// Desired number of replicas
 	remaining_replicas := this.Want_replicas

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list