Skip to content

Commit

Permalink
operator: explicitly check sync errors to set Available status
Browse files Browse the repository at this point in the history
The most common sync error that was see is RequiredPoolsFailed,
which does not mean that the operator itself is impaired. Let's
only set Available = False when operand syncs fail.
  • Loading branch information
kikisdeliveryservice committed Aug 20, 2021
1 parent 28c305d commit ecd414c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pkg/operator/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (optr *Operator) syncRelatedObjects() error {
}

// syncAvailableStatus applies the new condition to the mco's ClusterOperator object.
func (optr *Operator) syncAvailableStatus() error {
func (optr *Operator) syncAvailableStatus(ierr syncError) error {
co, err := optr.fetchClusterOperator()
if err != nil {
return err
Expand All @@ -100,12 +100,13 @@ func (optr *Operator) syncAvailableStatus() error {
return nil
}

degraded := cov1helpers.IsStatusConditionTrue(co.Status.Conditions, configv1.OperatorDegraded)
message := fmt.Sprintf("Cluster has deployed %s", co.Status.Versions)

available := configv1.ConditionTrue

if degraded {
// we will only be Available = False where there is a problem syncing
// operands of the MCO as that points to impaired operator functionality.
// RequiredPools failing but everything else being ok, should be just Degraded = True.
if ierr.err != nil && ierr.task != "RequiredPools" {
available = configv1.ConditionFalse
mcoObjectRef := &corev1.ObjectReference{
Kind: co.Kind,
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (optr *Operator) syncAll(syncFuncs []syncFunc) error {
return fmt.Errorf("error syncing degraded status: %v", err)
}

if err := optr.syncAvailableStatus(); err != nil {
if err := optr.syncAvailableStatus(syncErr); err != nil {
return fmt.Errorf("error syncing available status: %v", err)
}

Expand Down

0 comments on commit ecd414c

Please sign in to comment.