@@ -306,7 +306,7 @@ func (r *KustomizationReconciler) reconcile(
306306 }
307307
308308 // 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 )
310310 if err != nil {
311311 return kustomizev1 .KustomizationNotReady (
312312 kustomization ,
@@ -339,7 +339,7 @@ func (r *KustomizationReconciler) reconcile(
339339 }
340340
341341 // health assessment
342- err = r .checkHealth (statusPoller , kustomization , source .GetArtifact ().Revision )
342+ err = r .checkHealth (statusPoller , kustomization , source .GetArtifact ().Revision , changeSet != "" )
343343 if err != nil {
344344 return kustomizev1 .KustomizationNotReadySnapshot (
345345 kustomization ,
@@ -686,7 +686,7 @@ func (r *KustomizationReconciler) apply(kustomization kustomizev1.Kustomization,
686686 return changeSet , nil
687687}
688688
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 ) {
690690 changeSet , err := r .apply (kustomization , dirPath )
691691 if err != nil {
692692 // retry apply due to CRD/CR race
@@ -697,21 +697,21 @@ func (r *KustomizationReconciler) applyWithRetry(kustomization kustomizev1.Kusto
697697 "kustomization" , fmt .Sprintf ("%s/%s" , kustomization .GetNamespace (), kustomization .GetName ()))
698698 time .Sleep (delay )
699699 if changeSet , err := r .apply (kustomization , dirPath ); err != nil {
700- return err
700+ return "" , err
701701 } else {
702702 if changeSet != "" {
703703 r .event (kustomization , revision , events .EventSeverityInfo , changeSet , nil )
704704 }
705705 }
706706 } else {
707- return err
707+ return "" , err
708708 }
709709 } else {
710710 if changeSet != "" && kustomization .Status .LastAppliedRevision != revision {
711711 r .event (kustomization , revision , events .EventSeverityInfo , changeSet , nil )
712712 }
713713 }
714- return nil
714+ return changeSet , nil
715715}
716716
717717func (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
743743 return nil
744744}
745745
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 {
747747 if len (kustomization .Spec .HealthChecks ) == 0 {
748748 return nil
749749 }
@@ -754,7 +754,7 @@ func (r *KustomizationReconciler) checkHealth(statusPoller *polling.StatusPoller
754754 return err
755755 }
756756
757- if kustomization .Status .LastAppliedRevision != revision {
757+ if kustomization .Status .LastAppliedRevision != revision && changed {
758758 r .event (kustomization , revision , events .EventSeverityInfo , "Health check passed" , nil )
759759 }
760760 return nil
0 commit comments