mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
* master: report a volume server's maintenance mode in DataNodeInfo Planners that work from VolumeList had no way to tell a volume server in maintenance mode from any other, so they kept choosing it as a target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: give a volume server in maintenance mode no free capacity It refuses new data, so EC encode and balance planning must not pick it as a destination; it stays listed so it can still be a source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: never move shards to a volume server in maintenance mode It refuses every shard copy, and right after an evacuate it is the emptiest server, so the planner kept targeting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: count no free EC shard slots on a volume server in maintenance mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: report the volume server's error when it refuses a shard upload A refused ReceiveFile ends the stream, so Send returns only io.EOF and the job logged "failed to send file content: EOF" instead of the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: test that a refused shard upload reports the server's error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: never plan EC shard moves onto a volume server in maintenance mode Zero free slots alone did not keep it out: a shard the planner moves off the node credits a slot back, and a later move could take it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: test that ReceiveFileSendError reports a refusal in the response's Error field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec_balance: move the maintenance-target test to the end of the file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.4 KiB
Go
71 lines
2.4 KiB
Go
package ec
|
|
|
|
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"
|
|
)
|
|
|
|
// A volume server in maintenance mode refuses every shard copy, so it has no
|
|
// free shard slots whatever its disks report.
|
|
func TestCountFreeShardSlotsMaintenance(t *testing.T) {
|
|
dn := &master_pb.DataNodeInfo{
|
|
Id: "n1",
|
|
Maintenance: true,
|
|
DiskInfos: map[string]*master_pb.DiskInfo{
|
|
"": {MaxVolumeCount: 100},
|
|
},
|
|
}
|
|
if got := CountFreeShardSlots(dn, types.HardDriveType); got != 0 {
|
|
t.Errorf("maintenance node free shard slots = %d, want 0", got)
|
|
}
|
|
dn.Maintenance = false
|
|
if got := CountFreeShardSlots(dn, types.HardDriveType); got <= 0 {
|
|
t.Errorf("free shard slots after maintenance off = %d, want > 0", got)
|
|
}
|
|
}
|
|
|
|
// 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)
|
|
}
|