Skip to content

Commit

Permalink
fix(run): list cluster operator warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrt committed Jun 30, 2022
1 parent c787b22 commit 3d62d54
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pkg/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ func (r *RunOptions) PreRunCheck(kclient kubernetes.Interface) error {
}

// Check if Cluster Operators are stable
stable, err := checkClusterOperators(configClient)
if err != nil {
return err
}
if !stable {
errs := checkClusterOperators(configClient)
if errs != nil {
for _, err := range errs {
log.Warn(err)
}
return errors.New("All Cluster Operators must be available, not progressing, and not degraded before certification can run")
}

Expand Down Expand Up @@ -341,11 +341,12 @@ func (r *RunOptions) Run(kclient kubernetes.Interface, sclient sonobuoyclient.In
return err
}

func checkClusterOperators(configClient coclient.Interface) (bool, error) {
func checkClusterOperators(configClient coclient.Interface) []error {
var result []error
// List all Cluster Operators
coList, err := configClient.ConfigV1().ClusterOperators().List(context.TODO(), metav1.ListOptions{})
if err != nil {
return false, err
return []error{err}
}

// Each Cluster Operator should be available, not progressing, and not degraded
Expand All @@ -354,21 +355,21 @@ func checkClusterOperators(configClient coclient.Interface) (bool, error) {
switch cond.Type {
case configv1.OperatorAvailable:
if cond.Status == configv1.ConditionFalse {
return false, nil
result = append(result, errors.Errorf("%s is unavailable", co.Name))
}
case configv1.OperatorProgressing:
if cond.Status == configv1.ConditionTrue {
return false, nil
result = append(result, errors.Errorf("%s is still progressing", co.Name))
}
case configv1.OperatorDegraded:
if cond.Status == configv1.ConditionTrue {
return false, nil
result = append(result, errors.Errorf("%s is in degraded state", co.Name))
}
}
}
}

return true, nil
return result
}

// Check registry is in managed state. We assume Cluster Operator is stable.
Expand Down

0 comments on commit 3d62d54

Please sign in to comment.