mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-24 06:50:40 +02:00
refactor: extract EC orchestration into a shared weed/ec package (#10760)
* shell: move ErrorWaitGroup to weed/util * shell: remove unused CandidateEcNode and EcRack types * ec: extract EC orchestration logic from weed/shell into weed/ec Move the EC node/topology model, balance engine, encode pipeline, decode pipeline, and rebuild engine into a new weed/ec package so shell commands and maintenance workers can share the logic. Shell commands keep flag parsing and delegate through a small ec.Env (dial option, topology fetch, volume locations, lock check). Tests move along with the code. * shell: remove unused proportional-rebalance type stubs * ec: move scrub, replication check, and shard unmount engines into weed/ec * worker: share the EC generation-aware shard counter from weed/ec * ec: gofmt * shell: drop EC aliases with no remaining callers * ec: guard a missing topology hook and nil disk entries in topology helpers * ec: drop trailing newlines from decode error strings * ec: re-check the shell lock before applying shard unmounts * shell: trim -node entries in ec.scrub
This commit is contained in:
1 parent
f66d6ffc4a
commit
944d967502
30 files changed
+3830
-3648
No files matched your search
@@ -1,51 +0,0 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// countFreeShardSlots must report zero for a physically near-full disk even
|
||||
// though its slot math (MaxVolumeCount - VolumeCount) says it has room, so EC
|
||||
// placement never piles shards onto a full disk. Mirrors the volume #10160 gate.
|
||||
func TestCountFreeShardSlotsPhysicalDiskGate(t *testing.T) {
|
||||
const gb = uint64(1) << 30
|
||||
|
||||
mk := func(total, free uint64) *master_pb.DataNodeInfo {
|
||||
return &master_pb.DataNodeInfo{
|
||||
Id: "n1",
|
||||
DiskInfos: map[string]*master_pb.DiskInfo{
|
||||
"": {MaxVolumeCount: 100, VolumeCount: 0, DiskTotalBytes: total, DiskFreeBytes: free},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Physically empty: slot math applies, positive free slots.
|
||||
if got := countFreeShardSlots(mk(1000*gb, 900*gb), types.HardDriveType); got <= 0 {
|
||||
t.Errorf("physically empty disk free shard slots = %d, want > 0", got)
|
||||
}
|
||||
// Physically 96% full: gated to zero regardless of slot room.
|
||||
if got := countFreeShardSlots(mk(1000*gb, 40*gb), types.HardDriveType); got != 0 {
|
||||
t.Errorf("physically full disk free shard slots = %d, want 0", got)
|
||||
}
|
||||
// No byte report (older server): fall back to slot math, positive.
|
||||
if got := countFreeShardSlots(mk(0, 0), types.HardDriveType); got <= 0 {
|
||||
t.Errorf("unreported-bytes disk free shard slots = %d, want > 0 (slot fallback)", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseVolumeIdsFlag(t *testing.T) {
|
||||
vids, err := parseVolumeIdsFlag("101, 102,101, 103")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []needle.VolumeId{101, 102, 103}, vids)
|
||||
|
||||
_, err = parseVolumeIdsFlag("101,abc")
|
||||
assert.Error(t, err)
|
||||
|
||||
_, err = parseVolumeIdsFlag(" , ")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
Reference in new issue
Block a user