fix broken master health checking

This commit is contained in:
Chris Lu 2018-05-07 00:37:33 -07:00
parent be58993f47
commit cb6b1d8d41
4 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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{}

View file

@ -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)