[ARVADOS] updated: 579f6139c9c03fe1b08993746c87aa525ff314e9
git at public.curoverse.com
git at public.curoverse.com
Wed Nov 4 17:11:18 EST 2015
Summary of changes:
sdk/go/arvadosclient/arvadosclient.go | 20 ++++++
sdk/go/arvadosclient/arvadosclient_test.go | 76 +++++++++++++---------
services/keepstore/keepstore.go | 14 ++--
.../arvnodeman/computenode/dispatch/__init__.py | 22 +++++--
.../arvnodeman/computenode/dispatch/slurm.py | 4 +-
services/nodemanager/arvnodeman/daemon.py | 14 +++-
.../nodemanager/tests/test_computenode_dispatch.py | 14 +++-
services/nodemanager/tests/test_daemon.py | 20 ++++++
8 files changed, 131 insertions(+), 53 deletions(-)
via 579f6139c9c03fe1b08993746c87aa525ff314e9 (commit)
via 6b606a655410d9ed5116c3a3b6b6971bd90f9666 (commit)
via c74d29f1a53a1020520ffe6992ce4a39a350b5ef (commit)
via 57d3837ca9a8c5e4e71f9741931cc67e908fb3dd (commit)
via 0a43beae9c546b356220b281a432e1fa1986a305 (commit)
via 21bcf992a7e4eb806ea45c851356b2a50015fa65 (commit)
via 3c0ef3fc0cdb3f56d90442cc389ce4c2c94e8831 (commit)
via 3bef97ac46da8f5a7c322ec31c6bba4affb8ad80 (commit)
via 0a365f3d1a19fc27b402c9c742debf8975424b3f (commit)
via 242d3272391baeb95eb0a5e4e51627c2d54e7bc6 (commit)
via 59b22379a693d1fc15b4b77e58e47bac89e62660 (commit)
from cabef98fc6cec3b9616d0c76ba469184b9dce693 (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 579f6139c9c03fe1b08993746c87aa525ff314e9
Merge: cabef98 6b606a6
Author: radhika <radhika at curoverse.com>
Date: Wed Nov 4 17:11:10 2015 -0500
Merge branch 'master' into 5538-arvadosclient-retry
Conflicts:
sdk/go/arvadosclient/arvadosclient.go
diff --cc sdk/go/arvadosclient/arvadosclient.go
index efe1583,18e1074..a5d5a02
--- a/sdk/go/arvadosclient/arvadosclient.go
+++ b/sdk/go/arvadosclient/arvadosclient.go
@@@ -80,8 -84,7 +87,10 @@@ type ArvadosClient struct
// Discovery document
DiscoveryDoc Dict
+ lastClosedIdlesAt time.Time
++
+ // Number of retries
+ Retries int
}
// Create a new ArvadosClient, initialized with standard Arvados environment
@@@ -150,71 -151,45 +161,80 @@@ func (c ArvadosClient) CallRaw(method s
}
}
- if method == "GET" || method == "HEAD" {
- u.RawQuery = vals.Encode()
- if req, err = http.NewRequest(method, u.String(), nil); err != nil {
- return nil, err
+ // Make the request
+ remainingTries := 1 + c.Retries
+ var req *http.Request
+ var resp *http.Response
+ var errs []string
+ var badResp bool
+
+ for remainingTries > 0 {
+ if method == "GET" || method == "HEAD" {
+ u.RawQuery = vals.Encode()
+ if req, err = http.NewRequest(method, u.String(), nil); err != nil {
+ return nil, err
+ }
+ } else {
+ if req, err = http.NewRequest(method, u.String(), bytes.NewBufferString(vals.Encode())); err != nil {
+ return nil, err
+ }
+ req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
}
- } else {
- if req, err = http.NewRequest(method, u.String(), bytes.NewBufferString(vals.Encode())); err != nil {
- return nil, err
+
+ // Add api token header
+ req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", c.ApiToken))
+ if c.External {
+ req.Header.Add("X-External-Client", "1")
}
- req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
- }
- // Add api token header
- req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", c.ApiToken))
- if c.External {
- req.Header.Add("X-External-Client", "1")
- }
++ // POST and DELETE are not safe to retry automatically, so we minimize
++ // such failures by always using a new or recently active socket
++ if method == "POST" || method == "DELETE" {
++ if time.Since(c.lastClosedIdlesAt) > MaxIdleConnectionDuration {
++ c.lastClosedIdlesAt = time.Now()
++ c.Client.Transport.(*http.Transport).CloseIdleConnections()
++ }
++ }
+
- // POST and DELETE are not safe to retry automatically, so we minimize
- // such failures by always using a new or recently active socket
- if method == "POST" || method == "DELETE" {
- if time.Since(c.lastClosedIdlesAt) > MaxIdleConnectionDuration {
- c.lastClosedIdlesAt = time.Now()
- c.Client.Transport.(*http.Transport).CloseIdleConnections()
+ resp, err = c.Client.Do(req)
+ if err != nil {
+ if method == "GET" || method == "HEAD" || method == "PUT" {
+ errs = append(errs, err.Error())
+ badResp = false
+ remainingTries -= 1
+ continue
+ } else {
+ return nil, err
+ }
}
- }
- // Make the request
- var resp *http.Response
- if resp, err = c.Client.Do(req); err != nil {
- return nil, err
- }
+ if resp.StatusCode == http.StatusOK {
+ return resp.Body, nil
+ }
- if resp.StatusCode == http.StatusOK {
- return resp.Body, nil
+ defer resp.Body.Close()
+
+ if resp.StatusCode == 408 ||
+ resp.StatusCode == 409 ||
+ resp.StatusCode == 422 ||
+ resp.StatusCode == 423 ||
+ resp.StatusCode == 500 ||
+ resp.StatusCode == 502 ||
+ resp.StatusCode == 503 ||
+ resp.StatusCode == 504 {
+ badResp = true
+ remainingTries -= 1
+ continue
+ } else {
+ return nil, newAPIServerError(c.ApiServer, resp)
+ }
}
- defer resp.Body.Close()
- return nil, newAPIServerError(c.ApiServer, resp)
+ if badResp {
+ return nil, newAPIServerError(c.ApiServer, resp)
+ } else {
+ return nil, fmt.Errorf("%v", errs)
+ }
}
func newAPIServerError(ServerAddress string, resp *http.Response) APIServerError {
diff --cc sdk/go/arvadosclient/arvadosclient_test.go
index 26a4349,75af3ca..2f180b1
--- a/sdk/go/arvadosclient/arvadosclient_test.go
+++ b/sdk/go/arvadosclient/arvadosclient_test.go
@@@ -3,11 -3,10 +3,12 @@@ package arvadosclien
import (
"git.curoverse.com/arvados.git/sdk/go/arvadostest"
. "gopkg.in/check.v1"
+ "net"
"net/http"
"os"
+ "strings"
"testing"
+ "time"
)
// Gocheck boilerplate
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list