[ARVADOS] created: 1.1.2-135-g913baf3

Git user git at public.curoverse.com
Tue Jan 30 16:26:37 EST 2018


        at  913baf3c2d96000ea564821a9ae9163e991105a3 (commit)


commit 913baf3c2d96000ea564821a9ae9163e991105a3
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Tue Jan 30 16:04:34 2018 -0500

    13011: Fix 411 error when writing empty block to Azure storage.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/services/keepstore/azure_blob_volume.go b/services/keepstore/azure_blob_volume.go
index c64ac7a..62c856d 100644
--- a/services/keepstore/azure_blob_volume.go
+++ b/services/keepstore/azure_blob_volume.go
@@ -402,7 +402,17 @@ func (v *AzureBlobVolume) Put(ctx context.Context, loc string, block []byte) err
 	}()
 	errChan := make(chan error)
 	go func() {
-		errChan <- v.bsClient.CreateBlockBlobFromReader(v.ContainerName, loc, uint64(len(block)), bufr, nil)
+		var body io.Reader = bufr
+		if len(block) == 0 {
+			// We must send a "Content-Length: 0" header,
+			// but the http client interprets
+			// ContentLength==0 as "unknown" unless it can
+			// confirm by introspection that Body will
+			// read 0 bytes.
+			body = http.NoBody
+			bufr.Close()
+		}
+		errChan <- v.bsClient.CreateBlockBlobFromReader(v.ContainerName, loc, uint64(len(block)), body, nil)
 	}()
 	select {
 	case <-ctx.Done():
@@ -722,7 +732,9 @@ func (c *azureBlobClient) GetBlobRange(cname, bname, byterange string, hdrs map[
 
 func (c *azureBlobClient) CreateBlockBlobFromReader(cname, bname string, size uint64, rdr io.Reader, hdrs map[string]string) error {
 	c.stats.Tick(&c.stats.Ops, &c.stats.CreateOps)
-	rdr = NewCountingReader(rdr, c.stats.TickOutBytes)
+	if size != 0 {
+		rdr = NewCountingReader(rdr, c.stats.TickOutBytes)
+	}
 	err := c.client.CreateBlockBlobFromReader(cname, bname, size, rdr, hdrs)
 	c.stats.TickErr(err)
 	return err
diff --git a/services/keepstore/azure_blob_volume_test.go b/services/keepstore/azure_blob_volume_test.go
index 4256ec0..06216ed 100644
--- a/services/keepstore/azure_blob_volume_test.go
+++ b/services/keepstore/azure_blob_volume_test.go
@@ -124,6 +124,11 @@ func (h *azStubHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	if (r.Method == "PUT" || r.Method == "POST") && r.Header.Get("Content-Length") == "" {
+		rw.WriteHeader(http.StatusLengthRequired)
+		return
+	}
+
 	body, err := ioutil.ReadAll(r.Body)
 	if err != nil {
 		return

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list