@@ -169,7 +169,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
169169 log .Error (err , "unable to update status" )
170170 return ctrl.Result {Requeue : true }, err
171171 }
172- r .recordReadiness (kustomization , false )
172+ r .recordReadiness (kustomization )
173173 log .Info (msg )
174174 return ctrl.Result {}, nil
175175 }
@@ -189,7 +189,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
189189 log .Error (err , "unable to update status to progressing" )
190190 return ctrl.Result {Requeue : true }, err
191191 }
192- r .recordReadiness (kustomization , false )
192+ r .recordReadiness (kustomization )
193193
194194 // resolve source reference
195195 source , err := r .getSource (ctx , kustomization )
@@ -201,7 +201,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
201201 log .Error (err , "unable to update status for source not found" )
202202 return ctrl.Result {Requeue : true }, err
203203 }
204- r .recordReadiness (kustomization , false )
204+ r .recordReadiness (kustomization )
205205 log .Info (msg )
206206 // do not requeue, when the source is created the watcher should trigger a reconciliation
207207 return ctrl.Result {}, nil
@@ -218,7 +218,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
218218 log .Error (err , "unable to update status for artifact not found" )
219219 return ctrl.Result {Requeue : true }, err
220220 }
221- r .recordReadiness (kustomization , false )
221+ r .recordReadiness (kustomization )
222222 log .Info (msg )
223223 // do not requeue, when the artifact is created the watcher should trigger a reconciliation
224224 return ctrl.Result {}, nil
@@ -238,7 +238,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
238238 msg := fmt .Sprintf ("Dependencies do not meet ready condition, retrying in %s" , r .requeueDependency .String ())
239239 log .Error (err , msg )
240240 r .event (kustomization , source .GetArtifact ().Revision , events .EventSeverityInfo , msg , nil )
241- r .recordReadiness (kustomization , false )
241+ r .recordReadiness (kustomization )
242242 return ctrl.Result {RequeueAfter : r .requeueDependency }, nil
243243 }
244244 log .Info ("All dependencies area ready, proceeding with reconciliation" )
@@ -267,14 +267,14 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
267267 // requeue
268268 if reconcileErr != nil {
269269 // record the reconciliation error
270- r .recordReadiness (reconciledKustomization , false )
270+ r .recordReadiness (reconciledKustomization )
271271 return ctrl.Result {RequeueAfter : kustomization .Spec .Interval .Duration }, reconcileErr
272272 }
273273
274274 // record the reconciliation result
275275 r .event (reconciledKustomization , source .GetArtifact ().Revision , events .EventSeverityInfo ,
276276 "Update completed" , map [string ]string {"commit_status" : "update" })
277- r .recordReadiness (reconciledKustomization , false )
277+ r .recordReadiness (reconciledKustomization )
278278 return ctrl.Result {RequeueAfter : kustomization .Spec .Interval .Duration }, nil
279279}
280280
@@ -378,7 +378,7 @@ func (r *KustomizationReconciler) reconcile(
378378 }
379379
380380 // prune
381- err = r .prune (client , kustomization , snapshot , false )
381+ err = r .prune (client , kustomization , snapshot )
382382 if err != nil {
383383 return kustomizev1 .KustomizationNotReady (
384384 kustomization ,
@@ -548,15 +548,15 @@ func (r *KustomizationReconciler) reconcileDelete(ctx context.Context, log logr.
548548 log .Error (err , "Unable to prune for finalizer" )
549549 return ctrl.Result {}, err
550550 }
551- if err := r .prune (client , kustomization , kustomization .Status .Snapshot , true ); err != nil {
551+ if err := r .prune (client , kustomization , kustomization .Status .Snapshot ); err != nil {
552552 r .event (kustomization , kustomization .Status .LastAppliedRevision , events .EventSeverityError , "pruning for deleted resource failed" , nil )
553553 // Return the error so we retry the failed garbage collection
554554 return ctrl.Result {}, err
555555 }
556556 }
557557
558558 // Record deleted status
559- r .recordReadiness (kustomization , true )
559+ r .recordReadiness (kustomization )
560560
561561 // Remove our finalizer from the list and update it
562562 controllerutil .RemoveFinalizer (& kustomization , kustomizev1 .KustomizationFinalizer )
@@ -764,11 +764,11 @@ func (r *KustomizationReconciler) applyWithRetry(kustomization kustomizev1.Kusto
764764 return changeSet , nil
765765}
766766
767- func (r * KustomizationReconciler ) prune (client client.Client , kustomization kustomizev1.Kustomization , snapshot * kustomizev1.Snapshot , force bool ) error {
767+ func (r * KustomizationReconciler ) prune (client client.Client , kustomization kustomizev1.Kustomization , snapshot * kustomizev1.Snapshot ) error {
768768 if ! kustomization .Spec .Prune || kustomization .Status .Snapshot == nil || snapshot == nil {
769769 return nil
770770 }
771- if ! force && kustomization .Status .Snapshot .Checksum == snapshot .Checksum {
771+ if kustomization . DeletionTimestamp . IsZero () && kustomization .Status .Snapshot .Checksum == snapshot .Checksum {
772772 return nil
773773 }
774774
@@ -975,7 +975,7 @@ func (r *KustomizationReconciler) event(kustomization kustomizev1.Kustomization,
975975 }
976976}
977977
978- func (r * KustomizationReconciler ) recordReadiness (kustomization kustomizev1.Kustomization , deleted bool ) {
978+ func (r * KustomizationReconciler ) recordReadiness (kustomization kustomizev1.Kustomization ) {
979979 if r .MetricsRecorder == nil {
980980 return
981981 }
@@ -989,12 +989,12 @@ func (r *KustomizationReconciler) recordReadiness(kustomization kustomizev1.Kust
989989 return
990990 }
991991 if rc := meta .GetCondition (kustomization .Status .Conditions , meta .ReadyCondition ); rc != nil {
992- r .MetricsRecorder .RecordCondition (* objRef , * rc , deleted )
992+ r .MetricsRecorder .RecordCondition (* objRef , * rc , ! kustomization . DeletionTimestamp . IsZero () )
993993 } else {
994994 r .MetricsRecorder .RecordCondition (* objRef , meta.Condition {
995995 Type : meta .ReadyCondition ,
996996 Status : corev1 .ConditionUnknown ,
997- }, deleted )
997+ }, ! kustomization . DeletionTimestamp . IsZero () )
998998 }
999999}
10001000
0 commit comments