[ARVADOS] updated: 09663f039a11c585c664335026107ccc04fa9ad8

Git user git at public.curoverse.com
Tue Jul 26 16:31:54 EDT 2016


Summary of changes:
 services/keepstore/handlers.go       | 18 +++++++++---------
 services/keepstore/pull_worker.go    |  5 ++---
 services/keepstore/s3_volume.go      | 11 +++++++----
 services/keepstore/s3_volume_test.go |  7 +++++++
 4 files changed, 25 insertions(+), 16 deletions(-)

       via  09663f039a11c585c664335026107ccc04fa9ad8 (commit)
       via  1ea66586b805dba4d2335b71e65693f716a4851d (commit)
       via  a35b3dde2624e0555d3e32eb5b9af60f1a3cad8e (commit)
       via  7d1c161af5665945e36748e0e2c8bcd6ab6e3df7 (commit)
      from  5f47ebc3f5a136cd8932d7cf3aa4931274b6c0a2 (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 09663f039a11c585c664335026107ccc04fa9ad8
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Jul 26 16:30:17 2016 -0400

    8555: Report error during Untrash.

diff --git a/services/keepstore/s3_volume.go b/services/keepstore/s3_volume.go
index 75b2329..1f62f4a 100644
--- a/services/keepstore/s3_volume.go
+++ b/services/keepstore/s3_volume.go
@@ -577,7 +577,10 @@ func (v *S3Volume) EmptyTrash() {
 		recent, err := v.Bucket.Head("recent/"+loc, nil)
 		if err != nil && os.IsNotExist(v.translateError(err)) {
 			log.Printf("warning: %s: EmptyTrash: found trash marker %q but no %q (%s); calling Untrash", v, trash.Key, "recent/"+loc, err)
-			v.Untrash(loc)
+			err = v.Untrash(loc)
+			if err != nil {
+				log.Printf("error: %s: EmptyTrash: Untrash(%q): %s", v, loc, err)
+			}
 			continue
 		} else if err != nil {
 			log.Printf("warning: %s: EmptyTrash: HEAD %q: %s", v, "recent/"+loc, err)

commit 1ea66586b805dba4d2335b71e65693f716a4851d
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Jul 26 16:29:57 2016 -0400

    8555: golint

diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index f698982..a6798a9 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -73,7 +73,7 @@ func BadRequestHandler(w http.ResponseWriter, r *http.Request) {
 func GetBlockHandler(resp http.ResponseWriter, req *http.Request) {
 	if enforcePermissions {
 		locator := req.URL.Path[1:] // strip leading slash
-		if err := VerifySignature(locator, GetApiToken(req)); err != nil {
+		if err := VerifySignature(locator, GetAPIToken(req)); err != nil {
 			http.Error(resp, err.Error(), err.(*KeepError).HTTPCode)
 			return
 		}
@@ -184,7 +184,7 @@ func PutBlockHandler(resp http.ResponseWriter, req *http.Request) {
 	// Success; add a size hint, sign the locator if possible, and
 	// return it to the client.
 	returnHash := fmt.Sprintf("%s+%d", hash, req.ContentLength)
-	apiToken := GetApiToken(req)
+	apiToken := GetAPIToken(req)
 	if PermissionSecret != nil && apiToken != "" {
 		expiry := time.Now().Add(blobSignatureTTL)
 		returnHash = SignLocator(returnHash, apiToken, expiry)
@@ -196,7 +196,7 @@ func PutBlockHandler(resp http.ResponseWriter, req *http.Request) {
 // IndexHandler is a HandleFunc to address /index and /index/{prefix} requests.
 func IndexHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	if !IsDataManagerToken(GetApiToken(req)) {
+	if !IsDataManagerToken(GetAPIToken(req)) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		return
 	}
@@ -328,7 +328,7 @@ func DeleteHandler(resp http.ResponseWriter, req *http.Request) {
 	hash := mux.Vars(req)["hash"]
 
 	// Confirm that this user is an admin and has a token with unlimited scope.
-	var tok = GetApiToken(req)
+	var tok = GetAPIToken(req)
 	if tok == "" || !CanDelete(tok) {
 		http.Error(resp, PermissionError.Error(), PermissionError.HTTPCode)
 		return
@@ -419,7 +419,7 @@ type PullRequest struct {
 // PullHandler processes "PUT /pull" requests for the data manager.
 func PullHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	if !IsDataManagerToken(GetApiToken(req)) {
+	if !IsDataManagerToken(GetAPIToken(req)) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		return
 	}
@@ -455,7 +455,7 @@ type TrashRequest struct {
 // TrashHandler processes /trash requests.
 func TrashHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	if !IsDataManagerToken(GetApiToken(req)) {
+	if !IsDataManagerToken(GetAPIToken(req)) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		return
 	}
@@ -485,7 +485,7 @@ func TrashHandler(resp http.ResponseWriter, req *http.Request) {
 // UntrashHandler processes "PUT /untrash/{hash:[0-9a-f]{32}}" requests for the data manager.
 func UntrashHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	if !IsDataManagerToken(GetApiToken(req)) {
+	if !IsDataManagerToken(GetAPIToken(req)) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		return
 	}
@@ -714,10 +714,10 @@ func IsValidLocator(loc string) bool {
 
 var authRe = regexp.MustCompile(`^OAuth2\s+(.*)`)
 
-// GetApiToken returns the OAuth2 token from the Authorization
+// GetAPIToken returns the OAuth2 token from the Authorization
 // header of a HTTP request, or an empty string if no matching
 // token is found.
-func GetApiToken(req *http.Request) string {
+func GetAPIToken(req *http.Request) string {
 	if auth, ok := req.Header["Authorization"]; ok {
 		if match := authRe.FindStringSubmatch(auth[0]); match != nil {
 			return match[1]
diff --git a/services/keepstore/pull_worker.go b/services/keepstore/pull_worker.go
index 2626d4b..d53d106 100644
--- a/services/keepstore/pull_worker.go
+++ b/services/keepstore/pull_worker.go
@@ -2,7 +2,6 @@ package main
 
 import (
 	"crypto/rand"
-	"errors"
 	"fmt"
 	"git.curoverse.com/arvados.git/sdk/go/keepclient"
 	"io"
@@ -57,7 +56,7 @@ func PullItemAndProcess(pullRequest PullRequest, token string, keepClient *keepc
 		return
 	}
 	if reader == nil {
-		return errors.New(fmt.Sprintf("No reader found for : %s", signedLocator))
+		return fmt.Errorf("No reader found for : %s", signedLocator)
 	}
 	defer reader.Close()
 
@@ -67,7 +66,7 @@ func PullItemAndProcess(pullRequest PullRequest, token string, keepClient *keepc
 	}
 
 	if (readContent == nil) || (int64(len(readContent)) != contentLen) {
-		return errors.New(fmt.Sprintf("Content not found for: %s", signedLocator))
+		return fmt.Errorf("Content not found for: %s", signedLocator)
 	}
 
 	err = PutContent(readContent, pullRequest.Locator)

commit a35b3dde2624e0555d3e32eb5b9af60f1a3cad8e
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Jul 26 16:26:15 2016 -0400

    8555: Fix up comments.

diff --git a/services/keepstore/s3_volume.go b/services/keepstore/s3_volume.go
index 9b09bf7..75b2329 100644
--- a/services/keepstore/s3_volume.go
+++ b/services/keepstore/s3_volume.go
@@ -18,8 +18,8 @@ import (
 )
 
 var (
-	// Returned by Trash if that operation is impossible with the
-	// current config.
+	// ErrS3TrashDisabled is returned by Trash if that operation
+	// is impossible with the current config.
 	ErrS3TrashDisabled = fmt.Errorf("trash function is disabled because -trash-lifetime=0 and -s3-unsafe-delete=false")
 
 	s3AccessKeyFile string
diff --git a/services/keepstore/s3_volume_test.go b/services/keepstore/s3_volume_test.go
index 65ce2be..6ba3904 100644
--- a/services/keepstore/s3_volume_test.go
+++ b/services/keepstore/s3_volume_test.go
@@ -250,6 +250,7 @@ func (s *StubbedS3Suite) TestBackendStates(c *check.C) {
 			return loc, blk
 		}
 
+		// Check canGet
 		loc, blk := setupScenario()
 		buf := make([]byte, len(blk))
 		_, err := v.Get(loc, buf)
@@ -258,6 +259,7 @@ func (s *StubbedS3Suite) TestBackendStates(c *check.C) {
 			c.Check(os.IsNotExist(err), check.Equals, true)
 		}
 
+		// Call Trash, then check canTrash and canGetAfterTrash
 		loc, blk = setupScenario()
 		err = v.Trash(loc)
 		c.Check(err == nil, check.Equals, scenario.canTrash)
@@ -267,6 +269,7 @@ func (s *StubbedS3Suite) TestBackendStates(c *check.C) {
 			c.Check(os.IsNotExist(err), check.Equals, true)
 		}
 
+		// Call Untrash, then check canUntrash
 		loc, blk = setupScenario()
 		err = v.Untrash(loc)
 		c.Check(err == nil, check.Equals, scenario.canUntrash)
@@ -279,6 +282,8 @@ func (s *StubbedS3Suite) TestBackendStates(c *check.C) {
 			c.Check(err, check.IsNil)
 		}
 
+		// Call EmptyTrash, then check haveTrashAfterEmpty and
+		// freshAfterEmpty
 		loc, blk = setupScenario()
 		v.EmptyTrash()
 		_, err = v.Bucket.Head("trash/"+loc, nil)
@@ -291,6 +296,8 @@ func (s *StubbedS3Suite) TestBackendStates(c *check.C) {
 			c.Check(t.After(t0.Add(-time.Second)), check.Equals, true)
 		}
 
+		// Check for current Mtime after Put (applies to all
+		// scenarios)
 		loc, blk = setupScenario()
 		err = v.Put(loc, blk)
 		c.Check(err, check.IsNil)

commit 7d1c161af5665945e36748e0e2c8bcd6ab6e3df7
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Jul 26 16:20:30 2016 -0400

    8555: gofmt

diff --git a/services/keepstore/s3_volume.go b/services/keepstore/s3_volume.go
index d520d71..9b09bf7 100644
--- a/services/keepstore/s3_volume.go
+++ b/services/keepstore/s3_volume.go
@@ -589,7 +589,7 @@ func (v *S3Volume) EmptyTrash() {
 			continue
 		}
 		if trashT.Sub(recentT) < blobSignatureTTL {
-			if age := startT.Sub(recentT); age >= blobSignatureTTL - v.raceWindow {
+			if age := startT.Sub(recentT); age >= blobSignatureTTL-v.raceWindow {
 				// recent/loc is too old to protect
 				// loc from being Trashed again during
 				// the raceWindow that starts if we

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list