in internal/pkg/api/handleCheckin.go [1053:1085]
func calcUnhealthyReason(reqComponents []model.ComponentsItems) []string {
var unhealthyReason []string
hasUnhealthyInput := false
hasUnhealthyOutput := false
hasUnhealthyComponent := false
for _, component := range reqComponents {
if component.Status == FailedStatus || component.Status == DegradedStatus {
hasUnhealthyComponent = true
for _, unit := range component.Units {
if unit.Status == FailedStatus || unit.Status == DegradedStatus {
switch unit.Type {
case "input":
hasUnhealthyInput = true
case "output":
hasUnhealthyOutput = true
}
}
}
}
}
unhealthyReason = make([]string, 0)
if hasUnhealthyInput {
unhealthyReason = append(unhealthyReason, "input")
}
if hasUnhealthyOutput {
unhealthyReason = append(unhealthyReason, "output")
}
if !hasUnhealthyInput && !hasUnhealthyOutput && hasUnhealthyComponent {
unhealthyReason = append(unhealthyReason, "other")
}
return unhealthyReason
}