Skip to content

Commit

Permalink
chore: decreased indent level in setApplicationHealth (argoproj#10980)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Fesenko <[email protected]>

Signed-off-by: Mikhail Fesenko <[email protected]>
  • Loading branch information
proggga authored Oct 19, 2022
1 parent 6632454 commit 5d9d53c
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions controller/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,30 @@ func setApplicationHealth(resources []managedResource, statuses []appv1.Resource
savedErr = err
}
}
if healthStatus != nil {
if persistResourceHealth {
resHealth := appv1.HealthStatus{Status: healthStatus.Status, Message: healthStatus.Message}
statuses[i].Health = &resHealth
} else {
statuses[i].Health = nil
}

// Is health status is missing but resource has not built-in/custom health check then it should not affect parent app health
if _, hasOverride := healthOverrides[lua.GetConfigMapKey(gvk)]; healthStatus.Status == health.HealthStatusMissing && !hasOverride && health.GetHealthCheckFunc(gvk) == nil {
continue
}
if healthStatus == nil {
continue
}

// Missing or Unknown health status of child Argo CD app should not affect parent
if res.Kind == application.ApplicationKind && res.Group == application.Group && (healthStatus.Status == health.HealthStatusMissing || healthStatus.Status == health.HealthStatusUnknown) {
continue
}
if persistResourceHealth {
resHealth := appv1.HealthStatus{Status: healthStatus.Status, Message: healthStatus.Message}
statuses[i].Health = &resHealth
} else {
statuses[i].Health = nil
}

if health.IsWorse(appHealth.Status, healthStatus.Status) {
appHealth.Status = healthStatus.Status
}
// Is health status is missing but resource has not built-in/custom health check then it should not affect parent app health
if _, hasOverride := healthOverrides[lua.GetConfigMapKey(gvk)]; healthStatus.Status == health.HealthStatusMissing && !hasOverride && health.GetHealthCheckFunc(gvk) == nil {
continue
}

// Missing or Unknown health status of child Argo CD app should not affect parent
if res.Kind == application.ApplicationKind && res.Group == application.Group && (healthStatus.Status == health.HealthStatusMissing || healthStatus.Status == health.HealthStatusUnknown) {
continue
}

if health.IsWorse(appHealth.Status, healthStatus.Status) {
appHealth.Status = healthStatus.Status
}
}
if persistResourceHealth {
Expand Down

0 comments on commit 5d9d53c

Please sign in to comment.