[ARVADOS] created: 1.1.4-352-gdd97299
Git user
git at public.curoverse.com
Mon Jun 4 20:40:37 EDT 2018
at dd97299b6b3ce82b6a57e2838fbe3f81bb51f140 (commit)
commit dd97299b6b3ce82b6a57e2838fbe3f81bb51f140
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Mon Jun 4 21:39:18 2018 -0300
13431: Make keepproxy propagate X-Keep-Storage-Classes headers
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go
index 1617706..07fc63b 100644
--- a/services/keepproxy/keepproxy.go
+++ b/services/keepproxy/keepproxy.go
@@ -487,6 +487,15 @@ func (h *proxyHandler) Put(resp http.ResponseWriter, req *http.Request) {
locatorIn := mux.Vars(req)["locator"]
+ // Check if the client specified storage classes
+ if req.Header.Get("X-Keep-Storage-Classes") != "" {
+ var scl []string
+ for _, sc := range strings.Split(req.Header.Get("X-Keep-Storage-Classes"), ",") {
+ scl = append(scl, strings.Trim(sc, " "))
+ }
+ kc.StorageClasses = scl
+ }
+
_, err = fmt.Sscanf(req.Header.Get("Content-Length"), "%d", &expectLength)
if err != nil || expectLength < 0 {
err = LengthRequiredError
commit ed7698518d7eabea0f4e86acfb0660765fe31071
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Mon Jun 4 17:24:57 2018 -0300
13431: Adds storage class support to Keepclient.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/sdk/go/keepclient/keepclient.go b/sdk/go/keepclient/keepclient.go
index d88e767..169f145 100644
--- a/sdk/go/keepclient/keepclient.go
+++ b/sdk/go/keepclient/keepclient.go
@@ -101,6 +101,7 @@ type KeepClient struct {
Retries int
BlockCache *BlockCache
RequestID string
+ StorageClasses []string
// set to 1 if all writable services are of disk type, otherwise 0
replicasPerService int
diff --git a/sdk/go/keepclient/keepclient_test.go b/sdk/go/keepclient/keepclient_test.go
index 3b8de26..dc80ad7 100644
--- a/sdk/go/keepclient/keepclient_test.go
+++ b/sdk/go/keepclient/keepclient_test.go
@@ -93,16 +93,18 @@ func (s *ServerRequiredSuite) TestDefaultReplications(c *C) {
}
type StubPutHandler struct {
- c *C
- expectPath string
- expectApiToken string
- expectBody string
- handled chan string
+ c *C
+ expectPath string
+ expectApiToken string
+ expectBody string
+ expectStorageClass string
+ handled chan string
}
func (sph StubPutHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
sph.c.Check(req.URL.Path, Equals, "/"+sph.expectPath)
sph.c.Check(req.Header.Get("Authorization"), Equals, fmt.Sprintf("OAuth2 %s", sph.expectApiToken))
+ sph.c.Check(req.Header.Get("X-Keep-Storage-Classes"), Equals, sph.expectStorageClass)
body, err := ioutil.ReadAll(req.Body)
sph.c.Check(err, Equals, nil)
sph.c.Check(body, DeepEquals, []byte(sph.expectBody))
@@ -148,11 +150,12 @@ func (s *StandaloneSuite) TestUploadToStubKeepServer(c *C) {
"acbd18db4cc2f85cedef654fccc4a4d8",
"abc123",
"foo",
+ "hot",
make(chan string)}
UploadToStubHelper(c, st,
func(kc *KeepClient, url string, reader io.ReadCloser, writer io.WriteCloser, upload_status chan uploadStatus) {
-
+ kc.StorageClasses = []string{"hot"}
go kc.uploadToKeepServer(url, st.expectPath, reader, upload_status, int64(len("foo")), kc.getRequestID())
writer.Write([]byte("foo"))
@@ -170,6 +173,7 @@ func (s *StandaloneSuite) TestUploadToStubKeepServerBufferReader(c *C) {
"acbd18db4cc2f85cedef654fccc4a4d8",
"abc123",
"foo",
+ "",
make(chan string)}
UploadToStubHelper(c, st,
@@ -265,6 +269,7 @@ func (s *StandaloneSuite) TestPutB(c *C) {
hash,
"abc123",
"foo",
+ "",
make(chan string, 5)}
arv, _ := arvadosclient.MakeArvadosClient()
@@ -306,6 +311,7 @@ func (s *StandaloneSuite) TestPutHR(c *C) {
hash,
"abc123",
"foo",
+ "",
make(chan string, 5)}
arv, _ := arvadosclient.MakeArvadosClient()
@@ -354,6 +360,7 @@ func (s *StandaloneSuite) TestPutWithFail(c *C) {
hash,
"abc123",
"foo",
+ "",
make(chan string, 4)}
fh := FailHandler{
@@ -412,6 +419,7 @@ func (s *StandaloneSuite) TestPutWithTooManyFail(c *C) {
hash,
"abc123",
"foo",
+ "",
make(chan string, 1)}
fh := FailHandler{
@@ -989,6 +997,7 @@ func (s *StandaloneSuite) TestPutBWant2ReplicasWithOnlyOneWritableLocalRoot(c *C
hash,
"abc123",
"foo",
+ "",
make(chan string, 5)}
arv, _ := arvadosclient.MakeArvadosClient()
@@ -1027,6 +1036,7 @@ func (s *StandaloneSuite) TestPutBWithNoWritableLocalRoots(c *C) {
hash,
"abc123",
"foo",
+ "",
make(chan string, 5)}
arv, _ := arvadosclient.MakeArvadosClient()
@@ -1198,6 +1208,7 @@ func (s *StandaloneSuite) TestPutBRetry(c *C) {
Md5String("foo"),
"abc123",
"foo",
+ "",
make(chan string, 5)}}
arv, _ := arvadosclient.MakeArvadosClient()
diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index bfe8d5b..542827f 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -80,6 +80,9 @@ func (this *KeepClient) uploadToKeepServer(host string, hash string, body io.Rea
req.Header.Add("Authorization", "OAuth2 "+this.Arvados.ApiToken)
req.Header.Add("Content-Type", "application/octet-stream")
req.Header.Add(X_Keep_Desired_Replicas, fmt.Sprint(this.Want_replicas))
+ if len(this.StorageClasses) > 0 {
+ req.Header.Add("X-Keep-Storage-Classes", strings.Join(this.StorageClasses, ", "))
+ }
var resp *http.Response
if resp, err = this.httpClient().Do(req); err != nil {
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list