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
more error handling
Chris Lu20706d8cf267
diff --git a/weed-fs/src/cmd/weed/master.go b/weed-fs/src/cmd/weed/master.goindex d866e1580b..5fdc80c206 100644--- a/weed-fs/src/cmd/weed/master.go+++ b/weed-fs/src/cmd/weed/master.go@@ -77,6 +77,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {if topo.GetVolumeLayout(rt).GetActiveVolumeCount() <= 0 {if topo.FreeSpace() <= 0 {writeJson(w, r, map[string]string{"error": "No free volumes left!"})+ return} else {vg.GrowByType(rt, topo)}diff --git a/weed-fs/src/cmd/weed/upload.go b/weed-fs/src/cmd/weed/upload.goindex 89e0c34fc8..78b2452ffb 100644--- a/weed-fs/src/cmd/weed/upload.go+++ b/weed-fs/src/cmd/weed/upload.go@@ -6,7 +6,7 @@ import ("fmt""net/url""os"- "pkg/operation"+ "pkg/operation""pkg/util""strconv")@@ -60,7 +60,7 @@ func assign(count int) (*AssignResult, error) {return &ret, nil}-func upload(filename string, server string, fid string) (int) {+func upload(filename string, server string, fid string) (int, error) {if *IsDebug {fmt.Println("Start uploading file:", filename)}@@ -69,15 +69,19 @@ func upload(filename string, server string, fid string) (int) {if *IsDebug {fmt.Println("Failed to open file:", filename)}- panic(err.Error())+ return 0, err}- ret, _ := operation.Upload("http://"+server+"/"+fid, filename, fh)- return ret.Size+ ret, e := operation.Upload("http://"+server+"/"+fid, filename, fh)+ if e != nil {+ return 0, e+ }+ return ret.Size, e}type SubmitResult struct {- Fid string "fid"- Size int "size"+ Fid string "fid"+ Size int "size"+ Error string "error"}func submit(files []string) []SubmitResult {@@ -92,7 +96,11 @@ func submit(files []string) []SubmitResult {if index > 0 {fid = fid + "_" + strconv.Itoa(index)}- results[index].Size = upload(file, ret.PublicUrl, fid)+ results[index].Size, err = upload(file, ret.PublicUrl, fid)+ if err != nil {+ fid = ""+ results[index].Error = err.Error()+ }results[index].Fid = fid}return resultsdiff --git a/weed-fs/src/cmd/weed/volume.go b/weed-fs/src/cmd/weed/volume.goindex ebe67b0b9c..5e35d66317 100644--- a/weed-fs/src/cmd/weed/volume.go+++ b/weed-fs/src/cmd/weed/volume.go@@ -133,6 +133,7 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {writeJson(w, r, ne)} else {ret := store.Write(volumeId, needle)+ errorStatus := ""if ret > 0 || !store.HasVolume(volumeId) { //send to other replica locationsif r.FormValue("type") != "standard" {if distributedOperation(volumeId, func(location operation.Location) bool {@@ -142,16 +143,19 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {w.WriteHeader(http.StatusCreated)} else {ret = 0+ errorStatus = "Failed to write to replicas for volume " + volumeId.String()w.WriteHeader(http.StatusInternalServerError)}} else {w.WriteHeader(http.StatusCreated)}} else {+ errorStatus = "Failed to write to local disk"w.WriteHeader(http.StatusInternalServerError)}- m := make(map[string]uint32)+ m := make(map[string]interface{})m["size"] = ret+ m["error"] = errorStatuswriteJson(w, r, m)}}diff --git a/weed-fs/src/pkg/operation/upload_content.go b/weed-fs/src/pkg/operation/upload_content.goindex 652cbe71ba..7ed74e02f6 100644--- a/weed-fs/src/pkg/operation/upload_content.go+++ b/weed-fs/src/pkg/operation/upload_content.go@@ -9,10 +9,12 @@ import ("log""mime/multipart""net/http"+ "errors")type UploadResult struct {Size int+ Error string}func Upload(uploadUrl string, filename string, reader io.Reader) (*UploadResult, error) {@@ -38,5 +40,8 @@ func Upload(uploadUrl string, filename string, reader io.Reader) (*UploadResult,log.Println("failing to read upload resonse", uploadUrl, resp_body)return nil, err}+ if ret.Error != ""{+ return nil, errors.New(ret.Error)+ }return &ret, nil}