From ce5d7e5f88f72e26c1bb11cde33bb3bc981a640f Mon Sep 17 00:00:00 2001 From: Ilyes Ben Dlala Date: Tue, 11 Feb 2025 11:26:11 +0100 Subject: [PATCH] Handle conflict errors when updating Scan status log level 4 instead of an error since it is expected to happen Signed-off-by: Ilyes Ben Dlala --- .../controllers/execution/scans/scan_controller.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/operator/controllers/execution/scans/scan_controller.go b/operator/controllers/execution/scans/scan_controller.go index 2347346f99..18b251fddd 100644 --- a/operator/controllers/execution/scans/scan_controller.go +++ b/operator/controllers/execution/scans/scan_controller.go @@ -17,6 +17,7 @@ import ( "github.com/go-logr/logr" "github.com/prometheus/client_golang/prometheus" batch "k8s.io/api/batch/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -263,8 +264,17 @@ func (r *ScanReconciler) updateScanStatus(ctx context.Context, scan *executionv1 } if err := r.Status().Update(ctx, scan); err != nil { - r.Log.Error(err, "unable to update Scan status") - return err + if apierrors.IsConflict(err) { + r.Log.V(4).Info( + "Conflict while updating Scan status", + "scan", scan.Name, + "namespace", scan.Namespace, + ) + } else { + r.Log.Error(err, "unable to update Scan status") + return err + } + } return nil }