Skip to content

Commit

Permalink
Merge pull request openshift#2192 from pliurh/conflict_error
Browse files Browse the repository at this point in the history
OCPBUGS-26492: Not set CNO to degraded if API server returns conflict error
  • Loading branch information
openshift-merge-bot[bot] committed Feb 13, 2024
2 parents 138bdf1 + cad1e26 commit 7c7c54d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/clusterconfig/clusterconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ func (r *ReconcileClusterConfig) Reconcile(ctx context.Context, request reconcil
}

if err := apply.ApplyObject(ctx, r.client, operConfig, "clusterconfig"); err != nil {
r.status.SetDegraded(statusmanager.ClusterConfig, "ApplyOperatorConfig",
fmt.Sprintf("Error while trying to update operator configuration: %v", err))
// not set degraded if the err is a version conflict, but return a reconcile err for retry.
if !apierrors.IsConflict(err) {
r.status.SetDegraded(statusmanager.ClusterConfig, "ApplyOperatorConfig",
fmt.Sprintf("Error while trying to update operator configuration: %v", err))
}
log.Printf("Could not propagate configuration from network.config.openshift.io to network.operator.openshift.io: %v", err)
return reconcile.Result{}, fmt.Errorf("could not apply updated operator configuration: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/operconfig/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (r *ReconcileOperConfig) UpdateOperConfig(ctx context.Context, operConfig *
return fmt.Errorf("failed to transmute operator config, err: %v", err)
}
if err = apply.ApplyObject(ctx, r.client, us, "operconfig"); err != nil {
return fmt.Errorf("could not apply (%s) %s/%s, err: %v", operConfig.GroupVersionKind(), operConfig.GetNamespace(), operConfig.GetName(), err)
return fmt.Errorf("could not apply (%s) %s/%s, err: %w", operConfig.GroupVersionKind(), operConfig.GetNamespace(), operConfig.GetName(), err)
}
return nil
}
Expand Down
14 changes: 10 additions & 4 deletions pkg/controller/operconfig/operconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,11 @@ func (r *ReconcileOperConfig) Reconcile(ctx context.Context, request reconcile.R
// This will also commit the change back to the apiserver.
if err := r.MergeClusterConfig(ctx, operConfig); err != nil {
log.Printf("Failed to merge the cluster configuration: %v", err)
r.status.SetDegraded(statusmanager.OperatorConfig, "MergeClusterConfig",
fmt.Sprintf("Internal error while merging cluster configuration and operator configuration: %v", err))
// not set degraded if the err is a version conflict, but return a reconcile err for retry.
if !apierrors.IsConflict(err) {
r.status.SetDegraded(statusmanager.OperatorConfig, "MergeClusterConfig",
fmt.Sprintf("Internal error while merging cluster configuration and operator configuration: %v", err))
}
return reconcile.Result{}, err
}

Expand Down Expand Up @@ -342,8 +345,11 @@ func (r *ReconcileOperConfig) Reconcile(ctx context.Context, request reconcile.R
if !reflect.DeepEqual(operConfig, newOperConfig) {
if err := r.UpdateOperConfig(ctx, newOperConfig); err != nil {
log.Printf("Failed to update the operator configuration: %v", err)
r.status.SetDegraded(statusmanager.OperatorConfig, "UpdateOperatorConfig",
fmt.Sprintf("Internal error while updating operator configuration: %v", err))
// not set degraded if the err is a version conflict, but return a reconcile err for retry.
if !apierrors.IsConflict(err) {
r.status.SetDegraded(statusmanager.OperatorConfig, "UpdateOperatorConfig",
fmt.Sprintf("Internal error while updating operator configuration: %v", err))
}
return reconcile.Result{}, err
}
}
Expand Down

0 comments on commit 7c7c54d

Please sign in to comment.