Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (r *KustomizationReconciler) reconcile(
}

// apply
err = r.applyWithRetry(kustomization, source.GetArtifact().Revision, dirPath, 5*time.Second)
changeSet, err := r.applyWithRetry(kustomization, source.GetArtifact().Revision, dirPath, 5*time.Second)
if err != nil {
return kustomizev1.KustomizationNotReady(
kustomization,
Expand Down Expand Up @@ -367,7 +367,7 @@ func (r *KustomizationReconciler) reconcile(
}

// health assessment
err = r.checkHealth(statusPoller, kustomization, source.GetArtifact().Revision)
err = r.checkHealth(statusPoller, kustomization, source.GetArtifact().Revision, changeSet != "")
if err != nil {
return kustomizev1.KustomizationNotReadySnapshot(
kustomization,
Expand Down Expand Up @@ -685,7 +685,7 @@ func (r *KustomizationReconciler) apply(kustomization kustomizev1.Kustomization,
return changeSet, nil
}

func (r *KustomizationReconciler) applyWithRetry(kustomization kustomizev1.Kustomization, revision, dirPath string, delay time.Duration) error {
func (r *KustomizationReconciler) applyWithRetry(kustomization kustomizev1.Kustomization, revision, dirPath string, delay time.Duration) (string, error) {
changeSet, err := r.apply(kustomization, dirPath)
if err != nil {
// retry apply due to CRD/CR race
Expand All @@ -696,21 +696,21 @@ func (r *KustomizationReconciler) applyWithRetry(kustomization kustomizev1.Kusto
"kustomization", fmt.Sprintf("%s/%s", kustomization.GetNamespace(), kustomization.GetName()))
time.Sleep(delay)
if changeSet, err := r.apply(kustomization, dirPath); err != nil {
return err
return "", err
} else {
if changeSet != "" {
r.event(kustomization, revision, events.EventSeverityInfo, changeSet, nil)
}
}
} else {
return err
return "", err
}
} else {
if changeSet != "" && kustomization.Status.LastAppliedRevision != revision {
r.event(kustomization, revision, events.EventSeverityInfo, changeSet, nil)
}
}
return nil
return changeSet, nil
}

func (r *KustomizationReconciler) prune(client client.Client, kustomization kustomizev1.Kustomization, snapshot *kustomizev1.Snapshot, force bool) error {
Expand Down Expand Up @@ -742,7 +742,7 @@ func (r *KustomizationReconciler) prune(client client.Client, kustomization kust
return nil
}

func (r *KustomizationReconciler) checkHealth(statusPoller *polling.StatusPoller, kustomization kustomizev1.Kustomization, revision string) error {
func (r *KustomizationReconciler) checkHealth(statusPoller *polling.StatusPoller, kustomization kustomizev1.Kustomization, revision string, changed bool) error {
if len(kustomization.Spec.HealthChecks) == 0 {
return nil
}
Expand All @@ -753,7 +753,7 @@ func (r *KustomizationReconciler) checkHealth(statusPoller *polling.StatusPoller
return err
}

if kustomization.Status.LastAppliedRevision != revision {
if kustomization.Status.LastAppliedRevision != revision && changed {
r.event(kustomization, revision, events.EventSeverityInfo, "Health check passed", nil)
}
return nil
Expand Down