From 7d9a31a69b07441d727efc0afa83b8d9985ac793 Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Mon, 12 Aug 2019 13:21:27 -0400 Subject: [PATCH] Prevent global sync error degraded status flapping Signed-off-by: Monis Khan --- pkg/operator2/operator.go | 5 +++-- pkg/operator2/status.go | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/operator2/operator.go b/pkg/operator2/operator.go index 85d0746baf..fa995e94bf 100644 --- a/pkg/operator2/operator.go +++ b/pkg/operator2/operator.go @@ -260,10 +260,11 @@ func (c *authOperator) Sync(obj metav1.Object) error { syncErr := c.handleSync(operatorConfigCopy) // this is a catch all degraded state that we only set when we are otherwise not degraded globalDegradedErr := syncErr - if isDegraded(operatorConfigCopy) { + const globalDegradedPrefix = "OperatorSync" + if isDegradedIgnoreGlobal(operatorConfigCopy, globalDegradedPrefix) { globalDegradedErr = nil // unset because we are already degraded for some other reason } - handleDegraded(operatorConfigCopy, "OperatorSync", globalDegradedErr) + handleDegraded(operatorConfigCopy, globalDegradedPrefix, globalDegradedErr) if _, _, err := v1helpers.UpdateStatus(c.authOperatorConfigClient, func(status *operatorv1.OperatorStatus) error { // store a copy of our starting conditions, we need to preserve last transition time diff --git a/pkg/operator2/status.go b/pkg/operator2/status.go index b9e1f14302..6b47faefa3 100644 --- a/pkg/operator2/status.go +++ b/pkg/operator2/status.go @@ -25,9 +25,11 @@ func handleDegraded(operatorConfig *operatorv1.Authentication, prefix string, er }) } -func isDegraded(operatorConfig *operatorv1.Authentication) bool { +func isDegradedIgnoreGlobal(operatorConfig *operatorv1.Authentication, prefix string) bool { + globalDegraded := prefix + operatorv1.OperatorStatusTypeDegraded for _, condition := range operatorConfig.Status.Conditions { - if strings.HasSuffix(condition.Type, operatorv1.OperatorStatusTypeDegraded) && + if condition.Type != globalDegraded && // we want to know if we are degraded for something other than this + strings.HasSuffix(condition.Type, operatorv1.OperatorStatusTypeDegraded) && condition.Status == operatorv1.ConditionTrue { return true }