From be6d070222dff56c23ffeda628366713ade78608 Mon Sep 17 00:00:00 2001 From: Arunesh Dwivedi Date: Wed, 12 Aug 2026 09:00:23 +0000 Subject: [PATCH] fix: use float division for success ratio calculation (fixes #1163) The success ratio calculation used integer division: float64(successAndSkipped/imageJob.Status.Desired) This means 273/273 = 1 (integer division), but 272/273 = 0 (integer division), causing the job to incorrectly fail even with 99%+ success. The fix: cast to float64 before division: float64(successAndSkipped)/float64(imageJob.Status.Desired) Also fixes the log output which had the same integer division bug. Fixes #1163 Signed-off-by: Arunesh Dwivedi --- controllers/imagejob/imagejob_controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/imagejob/imagejob_controller.go b/controllers/imagejob/imagejob_controller.go index 8e8f683ca2..4afaf48f2a 100644 --- a/controllers/imagejob/imagejob_controller.go +++ b/controllers/imagejob/imagejob_controller.go @@ -279,11 +279,11 @@ func (r *Reconciler) handleRunningJob(ctx context.Context, imageJob *eraserv1.Im managerConfig := eraserConfig.Manager successRatio := managerConfig.ImageJob.SuccessRatio - if float64(successAndSkipped/imageJob.Status.Desired) < successRatio { + if float64(successAndSkipped)/float64(imageJob.Status.Desired) < successRatio { log.Info( "Marking job as failed", "success ratio", successRatio, - "actual ratio", success/imageJob.Status.Desired, + "actual ratio", float64(success)/float64(imageJob.Status.Desired), ) imageJob.Status.Phase = eraserv1.PhaseFailed }