@@ -606,7 +606,7 @@ func (r *ReconcileComplianceScan) phaseAggregatingHandler(h scanTypeHandler, log
606
606
logger .Info ("Creating an aggregator pod for scan" )
607
607
aggregator := r .newAggregatorPod (instance , logger )
608
608
if priorityClassExist , why := utils .ValidatePriorityClassExist (aggregator .Spec .PriorityClassName , r .Client ); ! priorityClassExist {
609
- log .Info (why , "aggregator" , aggregator .Name )
609
+ logger .Info (why , "aggregator" , aggregator .Name )
610
610
r .Recorder .Eventf (aggregator , corev1 .EventTypeWarning , "PriorityClass" , why + " aggregator:" + aggregator .Name )
611
611
aggregator .Spec .PriorityClassName = ""
612
612
}
@@ -658,19 +658,21 @@ func (r *ReconcileComplianceScan) phaseAggregatingHandler(h scanTypeHandler, log
658
658
return reconcile.Result {}, err
659
659
}
660
660
661
- instanceCopy := instance . DeepCopy ()
662
-
663
- if instanceCopy .Annotations == nil {
664
- instanceCopy .Annotations = make (map [string ]string )
661
+ // check if instance has any annotation before checking for check count
662
+ // to avoid nil pointer exception in case of missing annotation
663
+ if instance .Annotations == nil {
664
+ instance .Annotations = make (map [string ]string )
665
665
}
666
-
667
- // adding check count annotation
668
- instanceCopy .Annotations [compv1alpha1 .ComplianceCheckCountAnnotation ] = strconv .Itoa (checkCount )
669
-
670
- if err := r .Client .Update (context .TODO (), instanceCopy ); err != nil {
671
- logger .Error (err , "Cannot update the scan with the check count" )
672
- return reconcile.Result {}, err
666
+ if _ , ok := instance .Annotations [compv1alpha1 .ComplianceCheckCountAnnotation ]; ! ok {
667
+ instanceCopy := instance .DeepCopy ()
668
+ instanceCopy .Annotations [compv1alpha1 .ComplianceCheckCountAnnotation ] = strconv .Itoa (checkCount )
669
+ if err := r .Client .Update (context .TODO (), instanceCopy ); err != nil {
670
+ logger .Error (err , "Cannot update the scan with the check count" )
671
+ return reconcile.Result {}, err
672
+ }
673
+ return reconcile.Result {Requeue : true }, nil
673
674
}
675
+
674
676
instance .Status .Phase = compv1alpha1 .PhaseDone
675
677
instance .Status .EndTimestamp = & metav1.Time {Time : time .Now ()}
676
678
instance .Status .SetConditionReady ()
0 commit comments