Skip to content

Commit

Permalink
applylib: treat a failure to apply as health-unknown (#3496)
Browse files Browse the repository at this point in the history
This avoids logspam from our consistency assertions.
  • Loading branch information
justinsb committed Aug 25, 2022
1 parent 57b17a3 commit 29227c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions porch/controllers/remoterootsync/pkg/applyset/applyset.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ type ApplyResults struct {
total int
applySuccessCount int
applyFailCount int
healthyCount int
unhealthyCount int

healthyCount int
unhealthyCount int
// When apply fails, we don't know the health of the object
healthUnknownCount int
}

// AllApplied is true if the desired state has been successfully applied for all objects.
Expand All @@ -114,7 +117,7 @@ func (r *ApplyResults) AllHealthy() bool {
func (r *ApplyResults) checkInvariants() {
if r.total != (r.applySuccessCount + r.applyFailCount) {
klog.Warningf("consistency error (apply counts): %#v", r)
} else if r.total != (r.healthyCount + r.unhealthyCount) {
} else if r.total != (r.healthyCount + r.unhealthyCount + r.healthUnknownCount) {
// This "invariant" only holds when all objects could be applied
klog.Warningf("consistency error (healthy counts): %#v", r)
}
Expand All @@ -123,6 +126,7 @@ func (r *ApplyResults) checkInvariants() {
// applyError records that the apply of an object failed with an error.
func (r *ApplyResults) applyError(gvk schema.GroupVersionKind, nn types.NamespacedName, err error) {
r.applyFailCount++
r.healthUnknownCount++
klog.Warningf("error from apply on %s %s: %v", gvk, nn, err)
}

Expand Down

0 comments on commit 29227c0

Please sign in to comment.