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
Export REST file_{read,write}_failures metrics on volume servers (#9215)
Lisandro Pin93247d6de4e1
diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.goindex 1fad742db8..42263b9f80 100644--- a/weed/server/volume_server_handlers_read.go+++ b/weed/server/volume_server_handlers_read.go@@ -35,11 +35,13 @@ import (const reqIsProxied = "proxied"func NotFound(w http.ResponseWriter) {+ stats.VolumeServerFileReadFailures.Inc()stats.VolumeServerHandlerCounter.WithLabelValues(stats.ErrorGetNotFound).Inc()w.WriteHeader(http.StatusNotFound)}func InternalError(w http.ResponseWriter) {+ stats.VolumeServerFileReadFailures.Inc()stats.VolumeServerHandlerCounter.WithLabelValues(stats.ErrorGetInternal).Inc()w.WriteHeader(http.StatusInternalServerError)}diff --git a/weed/server/volume_server_handlers_write.go b/weed/server/volume_server_handlers_write.goindex 3477a411f9..c31e3503a2 100644--- a/weed/server/volume_server_handlers_write.go+++ b/weed/server/volume_server_handlers_write.go@@ -11,6 +11,7 @@ import ("github.com/seaweedfs/seaweedfs/weed/glog""github.com/seaweedfs/seaweedfs/weed/operation"+ "github.com/seaweedfs/seaweedfs/weed/stats""github.com/seaweedfs/seaweedfs/weed/storage/needle""github.com/seaweedfs/seaweedfs/weed/topology""github.com/seaweedfs/seaweedfs/weed/util/buffer_pool"@@ -28,6 +29,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {volumeId, ve := needle.NewVolumeId(vid)if ve != nil {glog.V(0).InfolnCtx(ctx, "NewVolumeId error:", ve)+ stats.VolumeServerFileWriteFailures.Inc()writeJsonError(w, r, http.StatusBadRequest, ve)return}@@ -42,6 +44,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {reqNeedle, originalSize, contentMd5, ne := needle.CreateNeedleFromRequest(r, vs.FixJpgOrientation, vs.fileSizeLimitBytes, bytesBuffer)if ne != nil {+ stats.VolumeServerFileWriteFailures.Inc()writeJsonError(w, r, http.StatusBadRequest, ne)return}@@ -50,6 +53,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {// use context.WithoutCancel to avoid context cancellation when the client connection is closedisUnchanged, writeError := topology.ReplicatedWrite(context.WithoutCancel(ctx), vs.GetMaster, vs.grpcDialOption, vs.store, volumeId, reqNeedle, r, contentMd5)if writeError != nil {+ stats.VolumeServerFileWriteFailures.Inc()writeJsonError(w, r, http.StatusInternalServerError, writeError)return}@@ -117,11 +121,13 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {if n.IsChunkedManifest() {chunkManifest, e := operation.LoadChunkManifest(n.Data, n.IsCompressed())if e != nil {+ stats.VolumeServerFileWriteFailures.Inc()writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Load chunks manifest error: %v", e))return}// make sure all chunks had deleted before delete manifestif e := chunkManifest.DeleteChunks(vs.GetMaster, false, vs.grpcDialOption); e != nil {+ stats.VolumeServerFileWriteFailures.Inc()writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Delete chunks error: %v", e))return}@@ -148,6 +154,7 @@ func writeDeleteResult(err error, count int64, w http.ResponseWriter, r *http.Rem["size"] = countwriteJsonQuiet(w, r, http.StatusAccepted, m)} else {+ stats.VolumeServerFileWriteFailures.Inc()writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Deletion Failed: %w", err))}}