Skip to content

Commit

Permalink
Improve the way to prioritize
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 b723484 commit 5aec9a7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pkg/model/application_live_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,29 @@ func (s *ApplicationLiveStateSnapshot) DetermineApplicationHealthStatus() {
return
}

s.HealthStatus = ApplicationLiveStateSnapshot_HEALTHY

unhealthy := false
unknown := false

for _, r := range app.Resources {
if r.HealthStatus == ResourceState_UNHEALTHY {
s.HealthStatus = ApplicationLiveStateSnapshot_UNHEALTHY
return
unhealthy = true
}
}

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

s.HealthStatus = ApplicationLiveStateSnapshot_HEALTHY
// prioritize unhealthy over unknown when these two statuses are both set.
if unhealthy {
s.HealthStatus = ApplicationLiveStateSnapshot_UNHEALTHY
return
}

if unknown {
s.HealthStatus = ApplicationLiveStateSnapshot_UNKNOWN
return
}
}

0 comments on commit 5aec9a7

Please sign in to comment.