Skip to content

Commit 6a93006

Browse files
authored
Merge pull request #2122 from CecileRobertMichon/errors-scope
Don't use error.Errorf in controllers to avoid showing stack traces in logs
2 parents c444fdb + ba4298e commit 6a93006

9 files changed

+9
-9
lines changed

controllers/azurecluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (acr *AzureClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque
179179
AzureCluster: azureCluster,
180180
})
181181
if err != nil {
182-
err = errors.Errorf("failed to create scope: %+v", err)
182+
err = errors.Wrap(err, "failed to create scope")
183183
acr.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "CreateClusterScopeFailed", err.Error())
184184
return reconcile.Result{}, err
185185
}

controllers/azurejson_machine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (r *AzureJSONMachineReconciler) Reconcile(ctx context.Context, req ctrl.Req
170170
AzureCluster: azureCluster,
171171
})
172172
if err != nil {
173-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
173+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
174174
}
175175

176176
apiVersion, kind := infrav1.GroupVersion.WithKind("AzureMachine").ToAPIVersionAndKind()

controllers/azurejson_machinepool_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (r *AzureJSONMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl
144144
AzureCluster: azureCluster,
145145
})
146146
if err != nil {
147-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
147+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
148148
}
149149

150150
apiVersion, kind := infrav1.GroupVersion.WithKind("AzureMachinePool").ToAPIVersionAndKind()

controllers/azurejson_machinetemplate_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (r *AzureJSONTemplateReconciler) Reconcile(ctx context.Context, req ctrl.Re
129129
AzureCluster: azureCluster,
130130
})
131131
if err != nil {
132-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
132+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
133133
}
134134

135135
apiVersion, kind := infrav1.GroupVersion.WithKind("AzureMachineTemplate").ToAPIVersionAndKind()

controllers/azuremachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (amr *AzureMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reque
217217
})
218218
if err != nil {
219219
amr.Recorder.Eventf(azureMachine, corev1.EventTypeWarning, "Error creating the machine scope", err.Error())
220-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
220+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
221221
}
222222

223223
// Always close the scope when exiting this function so we can persist any AzureMachine changes.

exp/controllers/azuremachinepool_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (ampr *AzureMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.
234234
ClusterScope: clusterScope,
235235
})
236236
if err != nil {
237-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
237+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
238238
}
239239

240240
// Always close the scope when exiting this function so we can persist any AzureMachine changes.

exp/controllers/azuremachinepoolmachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (ampmr *AzureMachinePoolMachineController) Reconcile(ctx context.Context, r
217217
ClusterScope: clusterScope,
218218
})
219219
if err != nil {
220-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
220+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
221221
}
222222

223223
// Always close the scope when exiting this function so we can persist any AzureMachine changes.

exp/controllers/azuremanagedcontrolplane_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) Reconcile(ctx context.Context,
178178
PatchTarget: azureControlPlane,
179179
})
180180
if err != nil {
181-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
181+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
182182
}
183183

184184
// Always patch when exiting so we can persist changes to finalizers and status

exp/controllers/azuremanagedmachinepool_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (ammpr *AzureManagedMachinePoolReconciler) Reconcile(ctx context.Context, r
205205
PatchTarget: infraPool,
206206
})
207207
if err != nil {
208-
return reconcile.Result{}, errors.Errorf("failed to create scope: %+v", err)
208+
return reconcile.Result{}, errors.Wrap(err, "failed to create scope")
209209
}
210210

211211
// Always patch when exiting so we can persist changes to finalizers and status

0 commit comments

Comments
 (0)