Skip to content

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.

setting http status code for failed requests

Chris Luce615b4e6f5b
diff --git a/weed-fs/src/cmd/weed/master.go b/weed-fs/src/cmd/weed/master.go
index 9ad99f1288..d9418daa4b 100644
--- a/weed-fs/src/cmd/weed/master.go
+++ b/weed-fs/src/cmd/weed/master.go
@@ -58,8 +58,12 @@ func dirLookupHandler(w http.ResponseWriter, r *http.Request) {
}
writeJson(w, r, map[string]interface{}{"locations": ret})
} else {
+ w.WriteHeader(http.StatusNotFound)
writeJson(w, r, map[string]string{"error": "volume id " + volumeId.String() + " not found. "})
}
+ } else {
+ w.WriteHeader(http.StatusNotAcceptable)
+ writeJson(w, r, map[string]string{"error": "unknown volumeId format " + vid})
}
}
@@ -74,11 +78,13 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
}
rt, err := storage.NewReplicationTypeFromString(repType)
if err != nil {
+ w.WriteHeader(http.StatusNotAcceptable)
writeJson(w, r, map[string]string{"error": err.Error()})
return
}
if topo.GetVolumeLayout(rt).GetActiveVolumeCount() <= 0 {
if topo.FreeSpace() <= 0 {
+ w.WriteHeader(http.StatusNotFound)
writeJson(w, r, map[string]string{"error": "No free volumes left!"})
return
} else {
@@ -89,6 +95,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
if err == nil {
writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl": dn.PublicUrl, "count": count})
} else {
+ w.WriteHeader(http.StatusNotAcceptable)
writeJson(w, r, map[string]string{"error": err.Error()})
}
}
@@ -128,6 +135,7 @@ func volumeGrowHandler(w http.ResponseWriter, r *http.Request) {
}
}
if err != nil {
+ w.WriteHeader(http.StatusNotAcceptable)
writeJson(w, r, map[string]string{"error": err.Error()})
} else {
writeJson(w, r, map[string]interface{}{"count": count})