Skip to content

Commit

Permalink
Prioritize unhealthy over unknown
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshiki Fujikane <[email protected]>
  • Loading branch information
ffjlabo committed Dec 26, 2024
1 parent 8e16586 commit b723484
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/model/application_live_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,14 @@ func (s *ApplicationLiveStateSnapshot) DetermineApplicationHealthStatus() {
s.HealthStatus = ApplicationLiveStateSnapshot_UNHEALTHY
return
}
}

for _, r := range app.Resources {
if r.HealthStatus == ResourceState_UNKNOWN {
s.HealthStatus = ApplicationLiveStateSnapshot_UNKNOWN
return
}
}

s.HealthStatus = ApplicationLiveStateSnapshot_HEALTHY
}
13 changes: 13 additions & 0 deletions pkg/model/application_live_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func TestApplicationLiveStateSnapshot_DetermineAppHealthStatus(t *testing.T) {
})
}
}

func TestApplicationLiveStateSnapshot_DetermineApplicationHealthStatus(t *testing.T) {
testcases := []struct {
name string
Expand Down Expand Up @@ -205,6 +206,18 @@ func TestApplicationLiveStateSnapshot_DetermineApplicationHealthStatus(t *testin
},
want: ApplicationLiveStateSnapshot_UNHEALTHY,
},
{
name: "unhealthy: prioritize unhealthy over unknown",
snapshot: &ApplicationLiveStateSnapshot{
ApplicationLiveState: &ApplicationLiveState{
Resources: []*ResourceState{
{HealthStatus: ResourceState_UNKNOWN},
{HealthStatus: ResourceState_UNHEALTHY},
},
},
},
want: ApplicationLiveStateSnapshot_UNHEALTHY,
},
{
name: "unknown: one of the resources is unknown",
snapshot: &ApplicationLiveStateSnapshot{
Expand Down

0 comments on commit b723484

Please sign in to comment.