[ARVADOS] updated: 37404e821668b6b9b1952a0a5a3b28901835884b

git at public.curoverse.com git at public.curoverse.com
Wed Sep 24 15:05:23 EDT 2014


Summary of changes:
 services/keepstore/handler_test.go | 120 ++++++++++++++++++++++++++++++++++---
 services/keepstore/handlers.go     |  58 ++++++++++++++++--
 services/keepstore/keepstore.go    |  14 +++--
 3 files changed, 174 insertions(+), 18 deletions(-)

       via  37404e821668b6b9b1952a0a5a3b28901835884b (commit)
       via  af09cce22f077b5a537e1b7eea8d98981de9f400 (commit)
       via  2b6f61a7d202b771be7e85c14fb4d1cb592142ec (commit)
       via  8934b505b0cdd6af699d910148046ede7c44b7da (commit)
       via  cbd11b4bfd5bcc637abe0e7678239dd1e7a2fbd2 (commit)
      from  2a8d349eaf2b1ac2254056ea32859f72a226d63f (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 37404e821668b6b9b1952a0a5a3b28901835884b
Merge: 2a8d349 af09cce
Author: Tim Pierce <twp at curoverse.com>
Date:   Wed Sep 24 15:05:03 2014 -0400

    Merge branch '3413-keep-trash-list'
    
    Closes #3413.


commit af09cce22f077b5a537e1b7eea8d98981de9f400
Author: Tim Pierce <twp at curoverse.com>
Date:   Wed Sep 24 11:45:47 2014 -0400

    3413: code review update

diff --git a/services/keepstore/handler_test.go b/services/keepstore/handler_test.go
index 53f24cf..0829ce9 100644
--- a/services/keepstore/handler_test.go
+++ b/services/keepstore/handler_test.go
@@ -669,6 +669,8 @@ func TestPullHandler(t *testing.T) {
 			t.Errorf("item %v could not be parsed as a PullRequest", item)
 		}
 	}
+
+	expectChannelEmpty(t, pullq.NextItem)
 }
 
 // TestTrashHandler
@@ -772,6 +774,8 @@ func TestTrashHandler(t *testing.T) {
 			t.Errorf("item %v could not be parsed as a TrashRequest", item)
 		}
 	}
+
+	expectChannelEmpty(t, trashq.NextItem)
 }
 
 // ====================
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 63db9ed..035b50f 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -66,8 +66,9 @@ func MakeRESTRouter() *mux.Router {
 	// for more details.
 	//
 	// Each handler parses the JSON list of block management requests
-	// in the message body, and delivers them to the pull queue or
-	// trash queue, respectively.
+	// in the message body, and replaces any existing pull queue or
+	// trash queue with their contentes.
+	//
 	rest.HandleFunc(`/pull`, PullHandler).Methods("PUT")
 	rest.HandleFunc(`/trash`, TrashHandler).Methods("PUT")
 
@@ -450,7 +451,7 @@ type PullRequest struct {
 
 func PullHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	if api_token := GetApiToken(req); !IsDataManagerToken(api_token) {
+	if !IsDataManagerToken(GetApiToken(req)) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		log.Printf("%s %s: %s\n", req.Method, req.URL, UnauthorizedError.Error())
 		return
@@ -491,7 +492,7 @@ type TrashRequest struct {
 
 func TrashHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	if api_token := GetApiToken(req); !IsDataManagerToken(api_token) {
+	if !IsDataManagerToken(GetApiToken(req)) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		log.Printf("%s %s: %s\n", req.Method, req.URL, UnauthorizedError.Error())
 		return

commit 2b6f61a7d202b771be7e85c14fb4d1cb592142ec
Author: Tim Pierce <twp at curoverse.com>
Date:   Mon Sep 22 13:50:14 2014 -0400

    3413: code review

diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 289b0c8..63db9ed 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -62,7 +62,7 @@ func MakeRESTRouter() *mux.Router {
 	// The PullHandler and TrashHandler process "PUT /pull" and "PUT
 	// /trash" requests from Data Manager.  These requests instruct
 	// Keep to replicate or delete blocks; see
-	// https://arvados.org/projects/orvos-private/wiki/Keep_Design_Doc
+	// https://arvados.org/projects/arvados/wiki/Keep_Design_Doc
 	// for more details.
 	//
 	// Each handler parses the JSON list of block management requests
@@ -450,8 +450,7 @@ type PullRequest struct {
 
 func PullHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	api_token := GetApiToken(req)
-	if !IsDataManagerToken(api_token) {
+	if api_token := GetApiToken(req); !IsDataManagerToken(api_token) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		log.Printf("%s %s: %s\n", req.Method, req.URL, UnauthorizedError.Error())
 		return
@@ -492,8 +491,7 @@ type TrashRequest struct {
 
 func TrashHandler(resp http.ResponseWriter, req *http.Request) {
 	// Reject unauthorized requests.
-	api_token := GetApiToken(req)
-	if !IsDataManagerToken(api_token) {
+	if api_token := GetApiToken(req); !IsDataManagerToken(api_token) {
 		http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
 		log.Printf("%s %s: %s\n", req.Method, req.URL, UnauthorizedError.Error())
 		return
diff --git a/services/keepstore/keepstore.go b/services/keepstore/keepstore.go
index d6eb6b2..c899d51 100644
--- a/services/keepstore/keepstore.go
+++ b/services/keepstore/keepstore.go
@@ -94,6 +94,11 @@ var KeepVM VolumeManager
 // The pull list manager and trash queue are threadsafe queues which
 // support atomic update operations. The PullHandler and TrashHandler
 // store results from Data Manager /pull and /trash requests here.
+//
+// See the Keep and Data Manager design documents for more details:
+// https://arvados.org/projects/arvados/wiki/Keep_Design_Doc
+// https://arvados.org/projects/arvados/wiki/Data_Manager_Design_Doc
+//
 var pullq *WorkQueue
 var trashq *WorkQueue
 

commit 8934b505b0cdd6af699d910148046ede7c44b7da
Author: Tim Pierce <twp at curoverse.com>
Date:   Mon Sep 22 13:27:32 2014 -0400

    3413: update for code review

diff --git a/services/keepstore/handler_test.go b/services/keepstore/handler_test.go
index 5528176..53f24cf 100644
--- a/services/keepstore/handler_test.go
+++ b/services/keepstore/handler_test.go
@@ -630,25 +630,25 @@ func TestPullHandler(t *testing.T) {
 	}
 	var testcases = []pullTest{
 		{
-			"pull: user token, good request",
+			"Valid pull list from an ordinary user",
 			RequestTester{"/pull", user_token, "PUT", good_json},
 			http.StatusUnauthorized,
 			"Unauthorized\n",
 		},
 		{
-			"pull: user token, bad request",
+			"Invalid pull request from an ordinary user",
 			RequestTester{"/pull", user_token, "PUT", bad_json},
 			http.StatusUnauthorized,
 			"Unauthorized\n",
 		},
 		{
-			"pull: data manager token, good request",
+			"Valid pull request from the data manager",
 			RequestTester{"/pull", data_manager_token, "PUT", good_json},
 			http.StatusOK,
 			"Received 3 pull requests\n",
 		},
 		{
-			"pull: data manager token, bad request",
+			"Invalid pull request from the data manager",
 			RequestTester{"/pull", data_manager_token, "PUT", bad_json},
 			http.StatusBadRequest,
 			"Bad Request\n",
@@ -663,12 +663,9 @@ func TestPullHandler(t *testing.T) {
 
 	// The Keep pull manager should have received one good list with 3
 	// requests on it.
-	var output_list = make([]PullRequest, 3)
 	for i := 0; i < 3; i++ {
 		item := <-pullq.NextItem
-		if pr, ok := item.(PullRequest); ok {
-			output_list[i] = pr
-		} else {
+		if _, ok := item.(PullRequest); !ok {
 			t.Errorf("item %v could not be parsed as a PullRequest", item)
 		}
 	}
@@ -736,25 +733,25 @@ func TestTrashHandler(t *testing.T) {
 
 	var testcases = []trashTest{
 		{
-			"trash: user token, good request",
+			"Valid trash list from an ordinary user",
 			RequestTester{"/trash", user_token, "PUT", good_json},
 			http.StatusUnauthorized,
 			"Unauthorized\n",
 		},
 		{
-			"trash: user token, bad request",
+			"Invalid trash list from an ordinary user",
 			RequestTester{"/trash", user_token, "PUT", bad_json},
 			http.StatusUnauthorized,
 			"Unauthorized\n",
 		},
 		{
-			"trash: data manager token, good request",
+			"Valid trash list from the data manager",
 			RequestTester{"/trash", data_manager_token, "PUT", good_json},
 			http.StatusOK,
 			"Received 3 trash requests\n",
 		},
 		{
-			"trash: data manager token, bad request",
+			"Invalid trash list from the data manager",
 			RequestTester{"/trash", data_manager_token, "PUT", bad_json},
 			http.StatusBadRequest,
 			"Bad Request\n",
@@ -769,12 +766,9 @@ func TestTrashHandler(t *testing.T) {
 
 	// The trash collector should have received one good list with 3
 	// requests on it.
-	var output_list = make([]TrashRequest, 3)
 	for i := 0; i < 3; i++ {
 		item := <-trashq.NextItem
-		if tr, ok := item.(TrashRequest); ok {
-			output_list[i] = tr
-		} else {
+		if _, ok := item.(TrashRequest); !ok {
 			t.Errorf("item %v could not be parsed as a TrashRequest", item)
 		}
 	}
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 038e812..289b0c8 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -60,9 +60,14 @@ func MakeRESTRouter() *mux.Router {
 	rest.HandleFunc(`/status.json`, StatusHandler).Methods("GET", "HEAD")
 
 	// The PullHandler and TrashHandler process "PUT /pull" and "PUT
-	// /trash" requests from Data Manager.  Each handler parses the
-	// JSON list of block management requests in the message body, and
-	// delivers them to the pull queue or trash queue, respectively.
+	// /trash" requests from Data Manager.  These requests instruct
+	// Keep to replicate or delete blocks; see
+	// https://arvados.org/projects/orvos-private/wiki/Keep_Design_Doc
+	// for more details.
+	//
+	// Each handler parses the JSON list of block management requests
+	// in the message body, and delivers them to the pull queue or
+	// trash queue, respectively.
 	rest.HandleFunc(`/pull`, PullHandler).Methods("PUT")
 	rest.HandleFunc(`/trash`, TrashHandler).Methods("PUT")
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list