Files
seaweedfs/weed/admin/topology/maintenance_test.go
T
Chris LuandClaude Opus 5.5 d6dee41f00 ec: do not place shards on a volume server in maintenance mode (#13227)
* 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>
2026-12-01 11:06:18 -08:00

56 lines
1.6 KiB
Go

package topology
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
)
func TestMaintenanceNodeHasNoCapacity(t *testing.T) {
t.Parallel()
topo := singleDiskTopologyInfoForCapacityTest()
rack := topo.DataCenterInfos[0].RackInfos[0]
rack.DataNodeInfos = append(rack.DataNodeInfos, &master_pb.DataNodeInfo{
Id: "node-b",
Maintenance: true,
DiskInfos: map[string]*master_pb.DiskInfo{
"hdd": {DiskId: 0, Type: "hdd", MaxVolumeCount: 1000},
},
})
at := NewActiveTopology(0)
if err := at.UpdateTopology(topo); err != nil {
t.Fatalf("UpdateTopology: %v", err)
}
if got := at.GetEffectiveAvailableCapacity("node-b", 0); got != 0 {
t.Errorf("GetEffectiveAvailableCapacity(node-b) = %d, want 0", got)
}
if got := at.GetEffectiveAvailableEcShardSlots("node-b", 0, 0); got != 0 {
t.Errorf("GetEffectiveAvailableEcShardSlots(node-b) = %d, want 0", got)
}
if got := at.GetEffectiveAvailableCapacity("node-a", 0); got != 1000 {
t.Errorf("GetEffectiveAvailableCapacity(node-a) = %d, want 1000", got)
}
for _, d := range at.GetDisksWithEffectiveCapacity(TaskTypeErasureCoding, "", 1) {
if d.NodeID == "node-b" {
t.Errorf("GetDisksWithEffectiveCapacity returned maintenance node-b")
}
}
for _, d := range at.GetAvailableDisks(TaskTypeBalance, "") {
if d.NodeID == "node-b" {
t.Errorf("GetAvailableDisks returned maintenance node-b")
}
}
sources := 0
for _, d := range at.GetDisksWithEffectiveCapacity(TaskTypeErasureCoding, "", 0) {
if d.NodeID == "node-b" {
sources++
}
}
if sources != 1 {
t.Errorf("maintenance node-b should stay listed with zero capacity, got %d entries", sources)
}
}