From 6f968626627916a41b299496fd758dd3c9e6c559 Mon Sep 17 00:00:00 2001 From: yanyiwu Date: Sun, 19 Apr 2015 19:00:20 +0800 Subject: [PATCH] FIXED: When RaftServer cannot find a leader, Return a more readable error. Before: curl -F "file=1234" "http://127.0.0.1:9333/submit" {"error":"Post http:///dir/assign: http: no Host in request URL"} After: curl -F "file=1234" "http://127.0.0.1:9333/submit" {"error":"Raft Server not initialized!"} --- go/weed/weed_server/master_server_handlers_admin.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/go/weed/weed_server/master_server_handlers_admin.go b/go/weed/weed_server/master_server_handlers_admin.go index 0f836ff24..64c64d1e8 100644 --- a/go/weed/weed_server/master_server_handlers_admin.go +++ b/go/weed/weed_server/master_server_handlers_admin.go @@ -133,7 +133,12 @@ func (ms *MasterServer) submitFromMasterServerHandler(w http.ResponseWriter, r * if ms.Topo.IsLeader() { submitForClientHandler(w, r, "localhost:"+strconv.Itoa(ms.port)) } else { - submitForClientHandler(w, r, ms.Topo.RaftServer.Leader()) + masterUrl, err := ms.Topo.Leader() + if err != nil { + writeJsonError(w, r, http.StatusInternalServerError, err) + } else { + submitForClientHandler(w, r, masterUrl) + } } }