diff --git a/controller/appcontroller_test.go b/controller/appcontroller_test.go index 05b5d42d7d4fcc..6898290e10127b 100644 --- a/controller/appcontroller_test.go +++ b/controller/appcontroller_test.go @@ -1709,7 +1709,7 @@ apps/Deployment: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - deployment.SetLabels(map[string]string{"status": tc.initialStatus}) + deployment.SetLabels(map[string]string{"status": tc.initialStatus}) ctrl.processAppRefreshQueueItem() apps, err := ctrl.appLister.List(labels.Everything()) require.NoError(t, err) diff --git a/controller/health.go b/controller/health.go index b1c457776886ea..0720578c7981fb 100644 --- a/controller/health.go +++ b/controller/health.go @@ -86,17 +86,15 @@ func setApplicationHealth(resources []managedResource, statuses []appv1.Resource if health.IsWorse(appHealth.Status, healthStatus.Status) { appHealth.Status = healthStatus.Status - if persistResourceHealth { - appHealth.LastTransitionTime = statuses[i].Health.LastTransitionTime - } else { - appHealth.LastTransitionTime = now - } - } else if healthStatus.Status == health.HealthStatusHealthy { - appHealth.LastTransitionTime = lastTransitionTime } } if persistResourceHealth { app.Status.ResourceHealthSource = appv1.ResourceHealthLocationInline + if app.Status.Health.Status == appHealth.Status { + appHealth.LastTransitionTime = lastTransitionTime + } else { + appHealth.LastTransitionTime = metav1.Now() + } } else { app.Status.ResourceHealthSource = appv1.ResourceHealthLocationAppTree }