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.

add descriptive error if no free volumes

Chris Lu73958e357dba
diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go
index 1699eaa368..29aff5c0b0 100644
--- a/weed/server/master_grpc_server_volume.go
+++ b/weed/server/master_grpc_server_volume.go
@@ -77,7 +77,7 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
if !ms.Topo.HasWritableVolume(option) {
if ms.Topo.AvailableSpaceFor(option) <= 0 {
- return nil, fmt.Errorf("No free volumes left!")
+ return nil, fmt.Errorf("no free volumes left for "+option.String())
}
ms.vgLock.Lock()
if !ms.Topo.HasWritableVolume(option) {
diff --git a/weed/server/master_server_handlers.go b/weed/server/master_server_handlers.go
index 117423ec67..a9fecc5bdb 100644
--- a/weed/server/master_server_handlers.go
+++ b/weed/server/master_server_handlers.go
@@ -113,7 +113,7 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
if !ms.Topo.HasWritableVolume(option) {
if ms.Topo.AvailableSpaceFor(option) <= 0 {
- writeJsonQuiet(w, r, http.StatusNotFound, operation.AssignResult{Error: "No free volumes left!"})
+ writeJsonQuiet(w, r, http.StatusNotFound, operation.AssignResult{Error: "No free volumes left for " + option.String()})
return
}
ms.vgLock.Lock()
diff --git a/weed/storage/super_block/replica_placement.go b/weed/storage/super_block/replica_placement.go
index fcccbba7d2..65ec53819a 100644
--- a/weed/storage/super_block/replica_placement.go
+++ b/weed/storage/super_block/replica_placement.go
@@ -6,9 +6,9 @@ import (
)
type ReplicaPlacement struct {
- SameRackCount int
- DiffRackCount int
- DiffDataCenterCount int
+ SameRackCount int `json:"node,omitempty"`
+ DiffRackCount int `json:"rack,omitempty"`
+ DiffDataCenterCount int `json:"dc,omitempty"`
}
func NewReplicaPlacementFromString(t string) (*ReplicaPlacement, error) {
diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go
index 4b0a4837ee..8941a049b6 100644
--- a/weed/topology/volume_growth.go
+++ b/weed/topology/volume_growth.go
@@ -1,6 +1,7 @@
package topology
import (
+ "encoding/json"
"fmt"
"github.com/chrislusf/seaweedfs/weed/storage/types"
"math/rand"
@@ -25,15 +26,15 @@ This package is created to resolve these replica placement issues:
*/
type VolumeGrowOption struct {
- Collection string
- ReplicaPlacement *super_block.ReplicaPlacement
- Ttl *needle.TTL
- DiskType types.DiskType
- Prealloacte int64
- DataCenter string
- Rack string
- DataNode string
- MemoryMapMaxSizeMb uint32
+ Collection string `json:"collection,omitempty"`
+ ReplicaPlacement *super_block.ReplicaPlacement `json:"replication,omitempty"`
+ Ttl *needle.TTL `json:"ttl,omitempty"`
+ DiskType types.DiskType `json:"disk,omitempty"`
+ Prealloacte int64 `json:"prealloacte,omitempty"`
+ DataCenter string `json:"dataCenter,omitempty"`
+ Rack string `json:"rack,omitempty"`
+ DataNode string `json:"dataNode,omitempty"`
+ MemoryMapMaxSizeMb uint32 `json:"memoryMapMaxSizeMb,omitempty"`
}
type VolumeGrowth struct {
@@ -41,7 +42,8 @@ type VolumeGrowth struct {
}
func (o *VolumeGrowOption) String() string {
- return fmt.Sprintf("Collection:%s, ReplicaPlacement:%v, Ttl:%v, DataCenter:%s, Rack:%s, DataNode:%s", o.Collection, o.ReplicaPlacement, o.Ttl, o.DataCenter, o.Rack, o.DataNode)
+ blob, _ := json.Marshal(o)
+ return string(blob)
}
func NewDefaultVolumeGrowth() *VolumeGrowth {