Merge pull request #435 from makkes/fix-health-checks

fix: don't skip all errors when recording health check status
This commit is contained in:
Stefan Prodan 2021-09-30 17:27:51 +03:00 committed by GitHub
commit ea369a0281
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -67,7 +67,10 @@ func (hc *KustomizeHealthCheck) Assess(pollInterval time.Duration) error {
if rs == nil {
continue
}
if rs.Error == nil {
// skip DeadlineExceeded errors because kstatus emits that error
// for every resource it's monitoring even when only one of them
// actually fails.
if rs.Error != context.DeadlineExceeded {
lastStatus[rs.Identifier] = rs
}
rss = append(rss, rs)
@ -94,7 +97,10 @@ func (hc *KustomizeHealthCheck) Assess(pollInterval time.Duration) error {
errors = append(errors, fmt.Sprintf("no status for %s available", id))
continue
}
if lastStatus[id].Status != status.CurrentStatus {
if lastStatus[id] == nil {
// this is only nil in the rare case where no status can be determined for the resource at all
errors = append(errors, fmt.Sprintf("%s (unknown status)", hc.objMetadataToString(rs.Identifier)))
} else if lastStatus[id].Status != status.CurrentStatus {
idString := hc.objMetadataToString(rs.Identifier)
var bld strings.Builder
bld.WriteString(fmt.Sprintf("%s (status '%s')", idString, lastStatus[id].Status))