From 1bcef02a6c730d7d8287e03c5226a61ff6e220a3 Mon Sep 17 00:00:00 2001 From: Lei Liu Date: Thu, 31 Oct 2019 14:25:05 +0800 Subject: [PATCH 1/2] fix dir/lookup and col/delete api 1, Fix Layouts first letter capitalized 2, Return http 204 when delete a collection Signed-off-by: Lei Liu --- weed/server/master_server_handlers_admin.go | 10 +++++++--- weed/topology/topology_map.go | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.go index 486bf31f4..42ec50dd5 100644 --- a/weed/server/master_server_handlers_admin.go +++ b/weed/server/master_server_handlers_admin.go @@ -18,9 +18,10 @@ import ( ) func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.Request) { - collection, ok := ms.Topo.FindCollection(r.FormValue("collection")) + collectionName := r.FormValue("collection") + collection, ok := ms.Topo.FindCollection(collectionName) if !ok { - writeJsonError(w, r, http.StatusBadRequest, fmt.Errorf("collection %s does not exist", r.FormValue("collection"))) + writeJsonError(w, r, http.StatusBadRequest, fmt.Errorf("collection %s does not exist", collectionName)) return } for _, server := range collection.ListVolumeServers() { @@ -35,7 +36,10 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.R return } } - ms.Topo.DeleteCollection(r.FormValue("collection")) + ms.Topo.DeleteCollection(collectionName) + + w.WriteHeader(http.StatusNoContent) + return } func (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) { diff --git a/weed/topology/topology_map.go b/weed/topology/topology_map.go index 37a88c9ed..0ad30f12e 100644 --- a/weed/topology/topology_map.go +++ b/weed/topology/topology_map.go @@ -23,7 +23,7 @@ func (t *Topology) ToMap() interface{} { } } } - m["layouts"] = layouts + m["Layouts"] = layouts return m } From 1294999d8b60b6ee8f562264c19caa95391371b0 Mon Sep 17 00:00:00 2001 From: Lei Liu Date: Thu, 31 Oct 2019 20:43:20 +0800 Subject: [PATCH 2/2] return error when garbageThreshold is not a valid float number Signed-off-by: Lei Liu --- weed/server/master_server_handlers_admin.go | 1 + 1 file changed, 1 insertion(+) diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.go index 42ec50dd5..a5d976008 100644 --- a/weed/server/master_server_handlers_admin.go +++ b/weed/server/master_server_handlers_admin.go @@ -57,6 +57,7 @@ func (ms *MasterServer) volumeVacuumHandler(w http.ResponseWriter, r *http.Reque gcThreshold, err = strconv.ParseFloat(gcString, 32) if err != nil { glog.V(0).Infof("garbageThreshold %s is not a valid float number: %v", gcString, err) + writeJsonError(w, r, http.StatusNotAcceptable, fmt.Errorf("garbageThreshold %s is not a valid float number", gcString)) return } }