Skip to content

Commit 0b77ba3

Browse files
authored
fix(operatorconditions): don't retry on 404 (#2679)
The controllers managing OperatorConditions can churn indefinitely, periodically producing error logs, when a CSV is deleted. To prevent this, don't retry when presented with select NOT_FOUND errors during reconciliation. Signed-off-by: Nick Hale <[email protected]>
1 parent 5cf7f1f commit 0b77ba3

File tree

2 files changed

+24
-31
lines changed

2 files changed

+24
-31
lines changed

pkg/controller/operators/operatorcondition_controller.go

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,34 @@ var _ reconcile.Reconciler = &OperatorConditionReconciler{}
9393

9494
func (r *OperatorConditionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
9595
// Set up a convenient log object so we don't have to type request over and over again
96-
log := r.log.WithValues("request", req)
97-
log.V(2).Info("reconciling operatorcondition")
96+
log := r.log.WithValues("request", req).V(1)
97+
log.Info("reconciling")
9898
metrics.EmitOperatorConditionReconcile(req.Namespace, req.Name)
9999

100100
operatorCondition := &operatorsv2.OperatorCondition{}
101-
err := r.Client.Get(context.TODO(), req.NamespacedName, operatorCondition)
102-
if err != nil {
103-
log.V(1).Error(err, "Unable to find operatorcondition")
104-
return ctrl.Result{}, err
101+
if err := r.Client.Get(ctx, req.NamespacedName, operatorCondition); err != nil {
102+
log.Info("Unable to find OperatorCondition")
103+
return ctrl.Result{}, client.IgnoreNotFound(err)
105104
}
106105

107-
err = r.ensureOperatorConditionRole(operatorCondition)
108-
if err != nil {
109-
log.V(1).Error(err, "Error ensuring OperatorCondition Role")
110-
return ctrl.Result{Requeue: true}, err
106+
if err := r.ensureOperatorConditionRole(operatorCondition); err != nil {
107+
log.Info("Error ensuring OperatorCondition Role")
108+
return ctrl.Result{}, err
111109
}
112110

113-
err = r.ensureOperatorConditionRoleBinding(operatorCondition)
114-
if err != nil {
115-
log.V(1).Error(err, "Error ensuring OperatorCondition RoleBinding")
116-
return ctrl.Result{Requeue: true}, err
111+
if err := r.ensureOperatorConditionRoleBinding(operatorCondition); err != nil {
112+
log.Info("Error ensuring OperatorCondition RoleBinding")
113+
return ctrl.Result{}, err
117114
}
118115

119-
err = r.ensureDeploymentEnvVars(operatorCondition)
120-
if err != nil {
121-
log.V(1).Error(err, "Error ensuring OperatorCondition Deployment EnvVars")
122-
return ctrl.Result{Requeue: true}, err
116+
if err := r.ensureDeploymentEnvVars(operatorCondition); err != nil {
117+
log.Info("Error ensuring OperatorCondition Deployment EnvVars")
118+
return ctrl.Result{}, err
123119
}
124120

125-
err = r.syncOperatorConditionStatus(operatorCondition)
126-
if err != nil {
127-
log.V(1).Error(err, "Error syncing OperatorCondition Status")
128-
return ctrl.Result{Requeue: true}, err
121+
if err := r.syncOperatorConditionStatus(operatorCondition); err != nil {
122+
log.Info("Error syncing OperatorCondition Status")
123+
return ctrl.Result{}, err
129124
}
130125

131126
return ctrl.Result{}, nil

pkg/controller/operators/operatorconditiongenerator_controller.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,13 @@ var _ reconcile.Reconciler = &OperatorConditionGeneratorReconciler{}
9090

9191
func (r *OperatorConditionGeneratorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
9292
// Set up a convenient log object so we don't have to type request over and over again
93-
log := r.log.WithValues("request", req)
93+
log := r.log.WithValues("request", req).V(1)
9494
metrics.EmitOperatorConditionGeneratorReconcile(req.Namespace, req.Name)
9595

9696
in := &operatorsv1alpha1.ClusterServiceVersion{}
97-
err := r.Client.Get(context.TODO(), req.NamespacedName, in)
98-
if err != nil {
99-
log.V(1).Error(err, "Unable to find ClusterServiceVersion")
100-
return ctrl.Result{}, err
97+
if err := r.Client.Get(ctx, req.NamespacedName, in); err != nil {
98+
log.Info("Unable to find ClusterServiceVersion")
99+
return ctrl.Result{}, client.IgnoreNotFound(err)
101100
}
102101

103102
operatorCondition := &operatorsv2.OperatorCondition{
@@ -113,10 +112,9 @@ func (r *OperatorConditionGeneratorReconciler) Reconcile(ctx context.Context, re
113112
}
114113
ownerutil.AddOwner(operatorCondition, in, false, true)
115114

116-
err = r.ensureOperatorCondition(*operatorCondition)
117-
if err != nil {
118-
log.V(1).Error(err, "Error ensuring ClusterServiceVersion")
119-
return ctrl.Result{Requeue: true}, err
115+
if err := r.ensureOperatorCondition(*operatorCondition); err != nil {
116+
log.Info("Error ensuring OperatorCondition")
117+
return ctrl.Result{}, err
120118
}
121119

122120
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)