Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions controller/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ func setApplicationHealth(resources []managedResource, statuses []appv1.Resource
appHealth.Status = healthStatus.Status
}
}
// if the status didn't change, don't update the timestamp
if app.Status.Health.Status == appHealth.Status && app.Status.Health.LastTransitionTime != nil {
appHealth.LastTransitionTime = app.Status.Health.LastTransitionTime
} else {
now := metav1.Now()
appHealth.LastTransitionTime = &now
}
if persistResourceHealth {
app.Status.ResourceHealthSource = appv1.ResourceHealthLocationInline
// if the status didn't change, don't update the timestamp
if app.Status.Health.Status == appHealth.Status && app.Status.Health.LastTransitionTime != nil {
appHealth.LastTransitionTime = app.Status.Health.LastTransitionTime
} else {
now := metav1.Now()
appHealth.LastTransitionTime = &now
}
} else {
app.Status.ResourceHealthSource = appv1.ResourceHealthLocationAppTree
}
Expand Down
1 change: 1 addition & 0 deletions controller/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func TestSetApplicationHealth_ResourceHealthNotPersisted(t *testing.T) {
healthStatus, err := setApplicationHealth(resources, resourceStatuses, lua.ResourceHealthOverrides{}, app, false)
require.NoError(t, err)
assert.Equal(t, health.HealthStatusDegraded, healthStatus.Status)
assert.NotNil(t, healthStatus.LastTransitionTime)

assert.Nil(t, resourceStatuses[0].Health)
}
Expand Down
2 changes: 2 additions & 0 deletions docs/operator-manual/upgrading/2.14-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ Example of a status field in the Application CR persisting health:
status:
health:
status: Healthy
lastTransitionTime: "2025-01-01T00:00:00Z"
resources:
- group: apps
health:
Expand All @@ -338,6 +339,7 @@ Example of a status field in the Application CR _not_ persisting health:
status:
health:
status: Healthy
lastTransitionTime: "2025-01-01T00:00:00Z"
resourceHealthSource: appTree
resources:
- group: apps
Expand Down
Loading