master: keep disk_id when registering volumes from incremental heartbeats (#10686)

The volume server names the directory index in every
VolumeShortInformationMessage, but NewVolumeInfoFromShort dropped it, so
volumes registered through the incremental new-volume path showed
disk_id 0 at the master until a full report -- misreporting multi-dir
servers in volume.list and the per-physical-disk topology views.

Claude-Session: https://claude.ai/code/session_01QdTEEPbg4MtcoEGwqbgtZC
This commit is contained in:
Chris Lu
2026-08-10 00:40:29 -07:00
committed by GitHub
parent 00c5572e8c
commit 65b9ae7704
2 changed files with 16 additions and 0 deletions
+1
View File
@@ -67,6 +67,7 @@ func NewVolumeInfoFromShort(m *master_pb.VolumeShortInformationMessage) (vi Volu
Id: needle.VolumeId(m.Id),
Collection: internVolumeString(m.Collection),
Version: needle.Version(m.Version),
DiskId: m.DiskId,
}
rp, e := super_block.NewReplicaPlacementFromByte(byte(m.ReplicaPlacement))
if e != nil {
+15
View File
@@ -3,6 +3,7 @@ package storage
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
)
@@ -25,3 +26,17 @@ func TestSortVolumeInfos(t *testing.T) {
}
}
}
func TestNewVolumeInfoFromShortKeepsDiskId(t *testing.T) {
vi, err := NewVolumeInfoFromShort(&master_pb.VolumeShortInformationMessage{
Id: 7,
Version: 3,
DiskId: 3,
})
if err != nil {
t.Fatal(err)
}
if vi.DiskId != 3 {
t.Fatalf("DiskId = %d, want 3", vi.DiskId)
}
}