[ARVADOS] updated: 370036888e75b509ebf84ba8337273f7b9146f37
Git user
git at public.curoverse.com
Thu May 18 13:27:18 EDT 2017
Summary of changes:
services/keepstore/handlers.go | 58 +++++++++++++++++++--------------------
services/keepstore/mounts_test.go | 4 +--
services/keepstore/volume.go | 11 ++++----
3 files changed, 35 insertions(+), 38 deletions(-)
via 370036888e75b509ebf84ba8337273f7b9146f37 (commit)
via d77b362ffa44f0fd48cb7127ca34d6d676fad8ca (commit)
from 42f5f3a29761ac9a943530157da376c798a4ac6d (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 370036888e75b509ebf84ba8337273f7b9146f37
Author: Tom Clegg <tom at curoverse.com>
Date: Thu May 18 13:26:36 2017 -0400
11644: Add DeviceID() to Volume interface.
diff --git a/services/keepstore/volume.go b/services/keepstore/volume.go
index 07b497c..86b3da6 100644
--- a/services/keepstore/volume.go
+++ b/services/keepstore/volume.go
@@ -232,6 +232,10 @@ type Volume interface {
// EmptyTrash looks for trashed blocks that exceeded TrashLifetime
// and deletes them from the volume.
EmptyTrash()
+
+ // Return a globally unique ID of the underlying storage
+ // device if possible, otherwise "".
+ DeviceID() string
}
// A VolumeWithExamples provides example configs to display in the
@@ -320,17 +324,12 @@ func MakeRRVolumeManager(volumes []Volume) *RRVolumeManager {
for _, v := range volumes {
mnt := &VolumeMount{
UUID: (*VolumeMount)(nil).generateUUID(),
- DeviceID: "",
+ DeviceID: v.DeviceID(),
ReadOnly: !v.Writable(),
Replication: v.Replication(),
Tier: 1,
volume: v,
}
- if v, ok := v.(interface {
- DeviceID() string
- }); ok {
- mnt.DeviceID = v.DeviceID()
- }
vm.iostats[v] = &ioStats{}
vm.mounts = append(vm.mounts, mnt)
vm.mountMap[mnt.UUID] = mnt
commit d77b362ffa44f0fd48cb7127ca34d6d676fad8ca
Author: Tom Clegg <tom at curoverse.com>
Date: Thu May 18 13:22:54 2017 -0400
11644: Unify block-index handlers. Move prefix arg to query string.
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 3356142..bd88acb 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -49,10 +49,10 @@ func MakeRESTRouter() *router {
rest.HandleFunc(`/{hash:[0-9a-f]{32}}`, PutBlockHandler).Methods("PUT")
rest.HandleFunc(`/{hash:[0-9a-f]{32}}`, DeleteHandler).Methods("DELETE")
// List all blocks stored here. Privileged client only.
- rest.HandleFunc(`/index`, IndexHandler).Methods("GET", "HEAD")
+ rest.HandleFunc(`/index`, rtr.IndexHandler).Methods("GET", "HEAD")
// List blocks stored here whose hash has the given prefix.
// Privileged client only.
- rest.HandleFunc(`/index/{prefix:[0-9a-f]{0,32}}`, IndexHandler).Methods("GET", "HEAD")
+ rest.HandleFunc(`/index/{prefix:[0-9a-f]{0,32}}`, rtr.IndexHandler).Methods("GET", "HEAD")
// Internals/debugging info (runtime.MemStats)
rest.HandleFunc(`/debug.json`, rtr.DebugHandler).Methods("GET", "HEAD")
@@ -61,9 +61,9 @@ func MakeRESTRouter() *router {
rest.HandleFunc(`/status.json`, rtr.StatusHandler).Methods("GET", "HEAD")
// List mounts: UUID, readonly, tier, device ID, ...
- rest.HandleFunc(`/mounts`, rtr.Mounts).Methods("GET")
- rest.HandleFunc(`/mounts/{uuid}/blocks`, rtr.MountBlocks).Methods("GET")
- rest.HandleFunc(`/mounts/{uuid}/blocks/{prefix:[0-9a-f]{0,32}}`, rtr.MountBlocks).Methods("GET")
+ rest.HandleFunc(`/mounts`, rtr.MountsHandler).Methods("GET")
+ rest.HandleFunc(`/mounts/{uuid}/blocks`, rtr.IndexHandler).Methods("GET")
+ rest.HandleFunc(`/mounts/{uuid}/blocks/`, rtr.IndexHandler).Methods("GET")
// Replace the current pull queue.
rest.HandleFunc(`/pull`, PullHandler).Methods("PUT")
@@ -228,18 +228,34 @@ func PutBlockHandler(resp http.ResponseWriter, req *http.Request) {
resp.Write([]byte(returnHash + "\n"))
}
-// IndexHandler is a HandleFunc to address /index and /index/{prefix} requests.
-func IndexHandler(resp http.ResponseWriter, req *http.Request) {
- // Reject unauthorized requests.
+// IndexHandler responds to "/index", "/index/{prefix}", and
+// "/mounts/{uuid}/blocks" requests.
+func (rtr *router) IndexHandler(resp http.ResponseWriter, req *http.Request) {
if !IsSystemAuth(GetAPIToken(req)) {
http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
return
}
prefix := mux.Vars(req)["prefix"]
+ if prefix == "" {
+ req.ParseForm()
+ prefix = req.Form.Get("prefix")
+ }
- for _, vol := range KeepVM.AllReadable() {
- if err := vol.IndexTo(prefix, resp); err != nil {
+ uuid := mux.Vars(req)["uuid"]
+
+ var vols []Volume
+ if uuid == "" {
+ vols = KeepVM.AllReadable()
+ } else if v := KeepVM.Lookup(uuid, false); v == nil {
+ http.Error(resp, "mount not found", http.StatusNotFound)
+ return
+ } else {
+ vols = []Volume{v}
+ }
+
+ for _, v := range vols {
+ if err := v.IndexTo(prefix, resp); err != nil {
// The only errors returned by IndexTo are
// write errors returned by resp.Write(),
// which probably means the client has
@@ -255,32 +271,14 @@ func IndexHandler(resp http.ResponseWriter, req *http.Request) {
resp.Write([]byte{'\n'})
}
-// Mounts responds to "GET /mounts" requests.
-func (rtr *router) Mounts(resp http.ResponseWriter, req *http.Request) {
+// MountsHandler responds to "GET /mounts" requests.
+func (rtr *router) MountsHandler(resp http.ResponseWriter, req *http.Request) {
err := json.NewEncoder(resp).Encode(KeepVM.Mounts())
if err != nil {
http.Error(resp, err.Error(), http.StatusInternalServerError)
}
}
-// MountBlocks responds to "GET /mounts/{uuid}/blocks" requests.
-func (rtr *router) MountBlocks(resp http.ResponseWriter, req *http.Request) {
- if !IsSystemAuth(GetAPIToken(req)) {
- http.Error(resp, UnauthorizedError.Error(), UnauthorizedError.HTTPCode)
- return
- }
-
- uuid := mux.Vars(req)["uuid"]
- prefix := mux.Vars(req)["prefix"]
- if v := KeepVM.Lookup(uuid, false); v == nil {
- http.Error(resp, "mount not found", http.StatusNotFound)
- } else if err := v.IndexTo(prefix, resp); err != nil {
- http.Error(resp, err.Error(), http.StatusInternalServerError)
- } else {
- resp.Write([]byte{'\n'})
- }
-}
-
// PoolStatus struct
type PoolStatus struct {
Alloc uint64 `json:"BytesAllocated"`
diff --git a/services/keepstore/mounts_test.go b/services/keepstore/mounts_test.go
index b44a08f..5659bcf 100644
--- a/services/keepstore/mounts_test.go
+++ b/services/keepstore/mounts_test.go
@@ -78,7 +78,7 @@ func (s *MountsSuite) TestMounts(c *check.C) {
c.Check(resp.Body.String(), check.Matches, TestHash+`\+[0-9]+ [0-9]+\n\n`)
// Partial index of first mount (one block matches prefix)
- resp = s.call("GET", "/mounts/"+mntList[0].UUID+"/blocks/"+TestHash[:2], tok)
+ resp = s.call("GET", "/mounts/"+mntList[0].UUID+"/blocks?prefix="+TestHash[:2], tok)
c.Check(resp.Code, check.Equals, http.StatusOK)
c.Check(resp.Body.String(), check.Matches, TestHash+`\+[0-9]+ [0-9]+\n\n`)
@@ -88,7 +88,7 @@ func (s *MountsSuite) TestMounts(c *check.C) {
c.Check(resp.Body.String(), check.Matches, TestHash2+`\+[0-9]+ [0-9]+\n\n`)
// Partial index of second mount (no blocks match prefix)
- resp = s.call("GET", "/mounts/"+mntList[1].UUID+"/blocks/"+TestHash[:2], tok)
+ resp = s.call("GET", "/mounts/"+mntList[1].UUID+"/blocks/?prefix="+TestHash[:2], tok)
c.Check(resp.Code, check.Equals, http.StatusOK)
c.Check(resp.Body.String(), check.Equals, "\n")
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list