aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYavor Konstantinov <7553015+sehnsucht13@users.noreply.github.com>2025-10-23 21:44:19 -0700
committerGitHub <noreply@github.com>2025-10-23 21:44:19 -0700
commit832df5265f6bcf0c71ee2256cfe9acb8be99ea86 (patch)
treea3e89ee024f2c9383b36ff5470bff35238f49f03
parent0abf70061b8664e0a79c0047523059b968194c00 (diff)
downloadseaweedfs-832df5265f6bcf0c71ee2256cfe9acb8be99ea86.tar.xz
seaweedfs-832df5265f6bcf0c71ee2256cfe9acb8be99ea86.zip
Fix 'NaN%' issue when running volume.fsck (#7368)
* Fix 'NaN%' issue when running volume.fsck - Running `volume.fsck` on an empty cluster will display 'NaN%'. * Refactor - Extract cound of orphan chunks in summary to new var. - Restore handling for 'NaN' for individual volumes. Its not necessary because the check is already done. * Make code more idiomatic
-rw-r--r--weed/shell/command_volume_fsck.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go
index 2ee4309e4..a8ccebf84 100644
--- a/weed/shell/command_volume_fsck.go
+++ b/weed/shell/command_volume_fsck.go
@@ -384,7 +384,12 @@ func (c *commandVolumeFsck) findExtraChunksInVolumeServers(dataNodeVolumeIdToVIn
}
if !applyPurging {
- pct := float64(totalOrphanChunkCount*100) / (float64(totalOrphanChunkCount + totalInUseCount))
+ var pct float64
+
+ if totalCount := totalOrphanChunkCount + totalInUseCount; totalCount > 0 {
+ pct = float64(totalOrphanChunkCount) * 100 / (float64(totalCount))
+ }
+
fmt.Fprintf(c.writer, "\nTotal\t\tentries:%d\torphan:%d\t%.2f%%\t%dB\n",
totalOrphanChunkCount+totalInUseCount, totalOrphanChunkCount, pct, totalOrphanDataSize)