SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
chore: filer healthz handler check filer store (#5208)
Konstantin Lebedev4e9ea1e628a4
diff --git a/weed/server/filer_server.go b/weed/server/filer_server.goindex d8b2ad8dca..a04fd1910b 100644--- a/weed/server/filer_server.go+++ b/weed/server/filer_server.go@@ -171,6 +171,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)}if defaultMux != readonlyMux {handleStaticResources(readonlyMux)+ readonlyMux.HandleFunc("/healthz", fs.filerHealthzHandler)readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)}diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.goindex c1b883f384..b5e070fb21 100644--- a/weed/server/filer_server_handlers.go+++ b/weed/server/filer_server_handlers.go@@ -1,6 +1,7 @@package weed_serverimport (+ "context""errors""net/http""os"@@ -9,7 +10,9 @@ import ("sync/atomic""time"+ "github.com/seaweedfs/seaweedfs/weed/filer""github.com/seaweedfs/seaweedfs/weed/glog"+ "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb""github.com/seaweedfs/seaweedfs/weed/security""github.com/seaweedfs/seaweedfs/weed/util"@@ -220,5 +223,10 @@ func (fs *FilerServer) maybeCheckJwtAuthorization(r *http.Request, isWrite bool)func (fs *FilerServer) filerHealthzHandler(w http.ResponseWriter, r *http.Request) {w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION)- w.WriteHeader(http.StatusOK)+ if _, err := fs.filer.Store.FindEntry(context.Background(), filer.TopicsDir); err != nil && err != filer_pb.ErrNotFound {+ glog.Warningf("filerHealthzHandler FindEntry: %+v", err)+ w.WriteHeader(http.StatusServiceUnavailable)+ } else {+ w.WriteHeader(http.StatusOK)+ }}