@@ -306,7 +306,7 @@ func (r *KustomizationReconciler) reconcile(
306
306
}
307
307
308
308
// apply
309
- err = r .applyWithRetry (kustomization , source .GetArtifact ().Revision , dirPath , 5 * time .Second )
309
+ changeSet , err : = r .applyWithRetry (kustomization , source .GetArtifact ().Revision , dirPath , 5 * time .Second )
310
310
if err != nil {
311
311
return kustomizev1 .KustomizationNotReady (
312
312
kustomization ,
@@ -339,7 +339,7 @@ func (r *KustomizationReconciler) reconcile(
339
339
}
340
340
341
341
// health assessment
342
- err = r .checkHealth (statusPoller , kustomization , source .GetArtifact ().Revision )
342
+ err = r .checkHealth (statusPoller , kustomization , source .GetArtifact ().Revision , changeSet != "" )
343
343
if err != nil {
344
344
return kustomizev1 .KustomizationNotReadySnapshot (
345
345
kustomization ,
@@ -686,7 +686,7 @@ func (r *KustomizationReconciler) apply(kustomization kustomizev1.Kustomization,
686
686
return changeSet , nil
687
687
}
688
688
689
- func (r * KustomizationReconciler ) applyWithRetry (kustomization kustomizev1.Kustomization , revision , dirPath string , delay time.Duration ) error {
689
+ func (r * KustomizationReconciler ) applyWithRetry (kustomization kustomizev1.Kustomization , revision , dirPath string , delay time.Duration ) ( string , error ) {
690
690
changeSet , err := r .apply (kustomization , dirPath )
691
691
if err != nil {
692
692
// retry apply due to CRD/CR race
@@ -697,21 +697,21 @@ func (r *KustomizationReconciler) applyWithRetry(kustomization kustomizev1.Kusto
697
697
"kustomization" , fmt .Sprintf ("%s/%s" , kustomization .GetNamespace (), kustomization .GetName ()))
698
698
time .Sleep (delay )
699
699
if changeSet , err := r .apply (kustomization , dirPath ); err != nil {
700
- return err
700
+ return "" , err
701
701
} else {
702
702
if changeSet != "" {
703
703
r .event (kustomization , revision , events .EventSeverityInfo , changeSet , nil )
704
704
}
705
705
}
706
706
} else {
707
- return err
707
+ return "" , err
708
708
}
709
709
} else {
710
710
if changeSet != "" && kustomization .Status .LastAppliedRevision != revision {
711
711
r .event (kustomization , revision , events .EventSeverityInfo , changeSet , nil )
712
712
}
713
713
}
714
- return nil
714
+ return changeSet , nil
715
715
}
716
716
717
717
func (r * KustomizationReconciler ) prune (client client.Client , kustomization kustomizev1.Kustomization , snapshot * kustomizev1.Snapshot , force bool ) error {
@@ -743,7 +743,7 @@ func (r *KustomizationReconciler) prune(client client.Client, kustomization kust
743
743
return nil
744
744
}
745
745
746
- func (r * KustomizationReconciler ) checkHealth (statusPoller * polling.StatusPoller , kustomization kustomizev1.Kustomization , revision string ) error {
746
+ func (r * KustomizationReconciler ) checkHealth (statusPoller * polling.StatusPoller , kustomization kustomizev1.Kustomization , revision string , changed bool ) error {
747
747
if len (kustomization .Spec .HealthChecks ) == 0 {
748
748
return nil
749
749
}
@@ -754,7 +754,7 @@ func (r *KustomizationReconciler) checkHealth(statusPoller *polling.StatusPoller
754
754
return err
755
755
}
756
756
757
- if kustomization .Status .LastAppliedRevision != revision {
757
+ if kustomization .Status .LastAppliedRevision != revision && changed {
758
758
r .event (kustomization , revision , events .EventSeverityInfo , "Health check passed" , nil )
759
759
}
760
760
return nil
0 commit comments