From a41afb9ed7c5487568452a05b13168b9d243292a Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Thu, 2 Mar 2023 14:31:50 -0500 Subject: [PATCH] 19986: Prevent division by zero when reporting max disk usage Arvados-DCO-1.1-Signed-off-by: Brett Smith --- lib/crunchstat/crunchstat.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crunchstat/crunchstat.go b/lib/crunchstat/crunchstat.go index 4241f5fb5b..ad1cc7a97a 100644 --- a/lib/crunchstat/crunchstat.go +++ b/lib/crunchstat/crunchstat.go @@ -177,7 +177,7 @@ func (r *Reporter) LogMaxima(logger logPrinter, memLimits map[string]int64) { logger.Printf("Total disk I/O on %s was %d bytes written and %d bytes read", disk, sample.txBytes, sample.rxBytes) } - if r.maxDiskSpaceSample.hasData { + if r.maxDiskSpaceSample.total > 0 { percentage := 100 * r.maxDiskSpaceSample.used / r.maxDiskSpaceSample.total logger.Printf("Maximum disk usage was %d%%, %d/%d bytes", percentage, r.maxDiskSpaceSample.used, r.maxDiskSpaceSample.total) -- 2.30.2