diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-11-04 21:50:04 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-04 21:50:04 -0800 |
| commit | ecdbe572ca26b7cbc00b584fa147839467585344 (patch) | |
| tree | 82c23dbf82cca1eca52a642eeacb23730ab8805d /weed/topology/disk.go | |
| parent | 17b23f61e1a0ac75222953fe701120462d176ff2 (diff) | |
| download | seaweedfs-ecdbe572ca26b7cbc00b584fa147839467585344.tar.xz seaweedfs-ecdbe572ca26b7cbc00b584fa147839467585344.zip | |
master: fix negative active volumes (#7440)
* fix negative active volumes
* address comments
* simplify
Diffstat (limited to 'weed/topology/disk.go')
| -rw-r--r-- | weed/topology/disk.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/weed/topology/disk.go b/weed/topology/disk.go index 8ca25c244..f27589916 100644 --- a/weed/topology/disk.go +++ b/weed/topology/disk.go @@ -176,6 +176,19 @@ func (d *Disk) doAddOrUpdateVolume(v storage.VolumeInfo) (isNew, isChanged bool) d.UpAdjustDiskUsageDelta(types.ToDiskType(v.DiskType), deltaDiskUsage) } isChanged = d.volumes[v.Id].ReadOnly != v.ReadOnly + if isChanged { + // Adjust active volume count when ReadOnly status changes + // Use a separate delta object to avoid affecting other metric adjustments + readOnlyDelta := &DiskUsageCounts{} + if v.ReadOnly { + // Changed from writable to read-only + readOnlyDelta.activeVolumeCount = -1 + } else { + // Changed from read-only to writable + readOnlyDelta.activeVolumeCount = 1 + } + d.UpAdjustDiskUsageDelta(types.ToDiskType(v.DiskType), readOnlyDelta) + } d.volumes[v.Id] = v } return |
