Skip to content

Commit ce5d7e5

Browse files
committed
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 <ilyes.bendlala@iteratec.com>
1 parent 35655f9 commit ce5d7e5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

operator/controllers/execution/scans/scan_controller.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/go-logr/logr"
1818
"github.com/prometheus/client_golang/prometheus"
1919
batch "k8s.io/api/batch/v1"
20+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
"k8s.io/apimachinery/pkg/runtime"
2223
ctrl "sigs.k8s.io/controller-runtime"
@@ -263,8 +264,17 @@ func (r *ScanReconciler) updateScanStatus(ctx context.Context, scan *executionv1
263264
}
264265

265266
if err := r.Status().Update(ctx, scan); err != nil {
266-
r.Log.Error(err, "unable to update Scan status")
267-
return err
267+
if apierrors.IsConflict(err) {
268+
r.Log.V(4).Info(
269+
"Conflict while updating Scan status",
270+
"scan", scan.Name,
271+
"namespace", scan.Namespace,
272+
)
273+
} else {
274+
r.Log.Error(err, "unable to update Scan status")
275+
return err
276+
}
277+
268278
}
269279
return nil
270280
}

0 commit comments

Comments
 (0)