@@ -14,6 +14,7 @@ import (
1414
1515 "github.com/go-logr/logr"
1616 "github.com/robfig/cron"
17+ apierrors "k8s.io/apimachinery/pkg/api/errors"
1718 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1819 "k8s.io/apimachinery/pkg/runtime"
1920 "k8s.io/apimachinery/pkg/types"
@@ -76,8 +77,17 @@ func (r *ScheduledScanReconciler) Reconcile(ctx context.Context, req ctrl.Reques
7677 log .V (4 ).Info ("Updating ScheduledScans Findings as they appear to have changed" )
7778 scheduledScan .Status .Findings = * lastFindings .DeepCopy ()
7879 if err := r .Status ().Update (ctx , & scheduledScan ); err != nil {
79- log .Error (err , "unable to update ScheduledScan status" )
80- return ctrl.Result {}, err
80+ if apierrors .IsConflict (err ) {
81+ r .Log .V (4 ).Info (
82+ "Conflict while updating ScheduledScan status, retrying" ,
83+ "scheduledScan" , scheduledScan .Name ,
84+ "namespace" , scheduledScan .Namespace ,
85+ )
86+ return ctrl.Result {RequeueAfter : 10 * time .Second }, nil
87+ } else {
88+ log .Error (err , "unable to update ScheduledScan status" )
89+ return ctrl.Result {}, err
90+ }
8191 }
8292 }
8393 }
@@ -178,8 +188,17 @@ func (r *ScheduledScanReconciler) Reconcile(ctx context.Context, req ctrl.Reques
178188 var now metav1.Time = metav1 .Now ()
179189 scheduledScan .Status .LastScheduleTime = & now
180190 if err := r .Status ().Update (ctx , & scheduledScan ); err != nil {
181- log .Error (err , "Unable to update ScheduledScan status" )
182- return ctrl.Result {}, err
191+ if apierrors .IsConflict (err ) {
192+ r .Log .V (4 ).Info (
193+ "Conflict while updating ScheduledScan status, retrying" ,
194+ "scheduledScan" , scheduledScan .Name ,
195+ "namespace" , scheduledScan .Namespace ,
196+ )
197+ return ctrl.Result {RequeueAfter : 10 * time .Second }, nil
198+ } else {
199+ log .Error (err , "Unable to update ScheduledScan status" )
200+ return ctrl.Result {}, err
201+ }
183202 }
184203
185204 // Recalculate next schedule
0 commit comments