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
This commit is contained in:
committed by
GitHub
parent
0abf70061b
commit
832df5265f
@@ -384,7 +384,12 @@ func (c *commandVolumeFsck) findExtraChunksInVolumeServers(dataNodeVolumeIdToVIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !applyPurging {
|
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",
|
fmt.Fprintf(c.writer, "\nTotal\t\tentries:%d\torphan:%d\t%.2f%%\t%dB\n",
|
||||||
totalOrphanChunkCount+totalInUseCount, totalOrphanChunkCount, pct, totalOrphanDataSize)
|
totalOrphanChunkCount+totalInUseCount, totalOrphanChunkCount, pct, totalOrphanDataSize)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user