[ARVADOS] updated: 496854e2b27a155190b0aacbc0adc820eb05cfcd
Git user
git at public.curoverse.com
Thu May 19 13:21:28 EDT 2016
Summary of changes:
services/keepstore/azure_blob_volume.go | 33 +++++++++++++++-------------
services/keepstore/azure_blob_volume_test.go | 1 +
services/keepstore/s3_volume.go | 4 +++-
services/keepstore/volume_generic_test.go | 2 +-
4 files changed, 23 insertions(+), 17 deletions(-)
via 496854e2b27a155190b0aacbc0adc820eb05cfcd (commit)
from 676ca01c9fe02da07c140ac07d746c3d1e326527 (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 496854e2b27a155190b0aacbc0adc820eb05cfcd
Author: radhika <radhika at curoverse.com>
Date: Thu May 19 13:20:46 2016 -0400
8556: unindent EmptyTrash code and count bytes deleted.
diff --git a/services/keepstore/azure_blob_volume.go b/services/keepstore/azure_blob_volume.go
index 6274f0d..99da2a3 100644
--- a/services/keepstore/azure_blob_volume.go
+++ b/services/keepstore/azure_blob_volume.go
@@ -134,7 +134,7 @@ func (v *AzureBlobVolume) Check() error {
return nil
}
-// Return NotFoundError if expires_at metadata attribute is found on the block
+// Return true if expires_at metadata attribute is found on the block
func (v *AzureBlobVolume) checkTrashed(loc string) (bool, map[string]string, error) {
metadata, err := v.bsClient.GetBlobMetadata(v.containerName, loc)
if err != nil {
@@ -473,30 +473,33 @@ func (v *AzureBlobVolume) EmptyTrash() {
break
}
for _, b := range resp.Blobs {
- // Check if it is expired
- expiresAtMetadata := b.Metadata["expires_at"]
- if expiresAtMetadata == "" {
+ // Check if the block is expired
+ if b.Metadata["expires_at"] == "" {
continue
}
blocksInTrash++
+ bytesInTrash += b.Properties.ContentLength
- expiresAt, err := strconv.ParseInt(expiresAtMetadata, 10, 64)
+ expiresAt, err := strconv.ParseInt(b.Metadata["expires_at"], 10, 64)
if err != nil {
- log.Printf("EmptyTrash: ParseInt(%v): %v", expiresAtMetadata, err)
+ log.Printf("EmptyTrash: ParseInt(%v): %v", b.Metadata["expires_at"], err)
continue
}
- if expiresAt <= time.Now().Unix() {
- err = v.bsClient.DeleteBlob(v.containerName, b.Name, map[string]string{
- "If-Match": b.Properties.Etag,
- })
- if err != nil {
- log.Printf("EmptyTrash: DeleteBlob(%v): %v", b.Name, err)
- continue
- }
- blocksDeleted++
+ if expiresAt > time.Now().Unix() {
+ continue
+ }
+
+ err = v.bsClient.DeleteBlob(v.containerName, b.Name, map[string]string{
+ "If-Match": b.Properties.Etag,
+ })
+ if err != nil {
+ log.Printf("EmptyTrash: DeleteBlob(%v): %v", b.Name, err)
+ continue
}
+ blocksDeleted++
+ bytesDeleted += b.Properties.ContentLength
}
if resp.NextMarker == "" {
break
diff --git a/services/keepstore/azure_blob_volume_test.go b/services/keepstore/azure_blob_volume_test.go
index 429c15e..5d556b3 100644
--- a/services/keepstore/azure_blob_volume_test.go
+++ b/services/keepstore/azure_blob_volume_test.go
@@ -203,6 +203,7 @@ func (h *azStubHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusBadRequest)
return
}
+ blob.Metadata = make(map[string]string)
for k, v := range r.Header {
if strings.HasPrefix(strings.ToLower(k), "x-ms-meta-") {
name := k[len("x-ms-meta-"):]
diff --git a/services/keepstore/s3_volume.go b/services/keepstore/s3_volume.go
index d068b2a..80a7c89 100644
--- a/services/keepstore/s3_volume.go
+++ b/services/keepstore/s3_volume.go
@@ -10,6 +10,7 @@ import (
"net/http"
"os"
"regexp"
+ "strings"
"time"
"github.com/AdRoll/goamz/aws"
@@ -310,7 +311,8 @@ func (v *S3Volume) isKeepBlock(s string) bool {
func (v *S3Volume) translateError(err error) error {
switch err := err.(type) {
case *s3.Error:
- if err.StatusCode == http.StatusNotFound && err.Code == "NoSuchKey" {
+ if (err.StatusCode == http.StatusNotFound && err.Code == "NoSuchKey") ||
+ strings.Contains(err.Error(), "Not Found") {
return os.ErrNotExist
}
// Other 404 errors like NoSuchVersion and
diff --git a/services/keepstore/volume_generic_test.go b/services/keepstore/volume_generic_test.go
index 44b2b86..f8fe0d0 100644
--- a/services/keepstore/volume_generic_test.go
+++ b/services/keepstore/volume_generic_test.go
@@ -455,7 +455,7 @@ func testDeleteOldBlock(t TB, factory TestableVolumeFactory) {
}
_, err := v.Mtime(TestHash)
- if err == nil {
+ if err == nil || !os.IsNotExist(err) {
t.Fatalf("os.IsNotExist(%v) should have been true", err)
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list