Browse Source

fix broken master health checking

pull/655/head
Chris Lu 7 years ago
parent
commit
cb6b1d8d41
  1. 5
      weed/server/common.go
  2. 2
      weed/server/filer_server.go
  3. 3
      weed/server/filer_server_handlers_api.go
  4. 3
      weed/server/master_server.go

5
weed/server/common.go

@ -170,6 +170,11 @@ func parseURLPath(path string) (vid, fid, filename, ext string, isVolumeIdOnly b
return return
} }
func statsHealthHandler(w http.ResponseWriter, r *http.Request) {
m := make(map[string]interface{})
m["Version"] = util.VERSION
writeJsonQuiet(w, r, http.StatusOK, m)
}
func statsCounterHandler(w http.ResponseWriter, r *http.Request) { func statsCounterHandler(w http.ResponseWriter, r *http.Request) {
m := make(map[string]interface{}) m := make(map[string]interface{})
m["Version"] = util.VERSION m["Version"] = util.VERSION

2
weed/server/filer_server.go

@ -185,7 +185,7 @@ func (fs *FilerServer) detectHealthyMaster(masterNode string) (master string, e
} }
func checkMaster(masterNode string) error { func checkMaster(masterNode string) error {
statUrl := "http://" + masterNode + "/stats"
statUrl := "http://" + masterNode + "/stats/health"
glog.V(4).Infof("Connecting to %s ...", statUrl) glog.V(4).Infof("Connecting to %s ...", statUrl)
_, e := util.Get(statUrl) _, e := util.Get(statUrl)
return e return e

3
weed/server/filer_server_handlers_api.go

@ -20,6 +20,9 @@ func (fs *FilerServer) apiHandler(w http.ResponseWriter, r *http.Request) {
glog.V(0).Infoln("failing to read request", r.RequestURI, request) glog.V(0).Infoln("failing to read request", r.RequestURI, request)
writeJsonError(w, r, http.StatusInternalServerError, err) writeJsonError(w, r, http.StatusInternalServerError, err)
} }
glog.V(2).Infof("api request: %+v", apiRequest)
switch apiRequest.Command { switch apiRequest.Command {
case "lookupDirectoryEntry": case "lookupDirectoryEntry":
res := filer.LookupDirectoryEntryResult{} res := filer.LookupDirectoryEntryResult{}

3
weed/server/master_server.go

@ -75,9 +75,10 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
r.HandleFunc("/vol/vacuum", ms.proxyToLeader(ms.guard.WhiteList(ms.volumeVacuumHandler))) r.HandleFunc("/vol/vacuum", ms.proxyToLeader(ms.guard.WhiteList(ms.volumeVacuumHandler)))
r.HandleFunc("/submit", ms.guard.WhiteList(ms.submitFromMasterServerHandler)) r.HandleFunc("/submit", ms.guard.WhiteList(ms.submitFromMasterServerHandler))
r.HandleFunc("/delete", ms.guard.WhiteList(ms.deleteFromMasterServerHandler)) r.HandleFunc("/delete", ms.guard.WhiteList(ms.deleteFromMasterServerHandler))
r.HandleFunc("/{fileId}", ms.proxyToLeader(ms.redirectHandler))
r.HandleFunc("/stats/health", ms.guard.WhiteList(statsHealthHandler))
r.HandleFunc("/stats/counter", ms.guard.WhiteList(statsCounterHandler)) r.HandleFunc("/stats/counter", ms.guard.WhiteList(statsCounterHandler))
r.HandleFunc("/stats/memory", ms.guard.WhiteList(statsMemoryHandler)) r.HandleFunc("/stats/memory", ms.guard.WhiteList(statsMemoryHandler))
r.HandleFunc("/{fileId}", ms.proxyToLeader(ms.redirectHandler))
ms.Topo.StartRefreshWritableVolumes(garbageThreshold, ms.preallocate) ms.Topo.StartRefreshWritableVolumes(garbageThreshold, ms.preallocate)

Loading…
Cancel
Save