Skip to content

Commit 2854412

Browse files
authored
Fix error handling (#148)
In some cases, the resulting error is not handled / logged, and it should.
1 parent 5b06b35 commit 2854412

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

bootstrap/controllers/ck8sconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (r *CK8sConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
166166
patchOpts = append(patchOpts, patch.WithStatusObservedGeneration{})
167167
}
168168
if err := patchHelper.Patch(ctx, config, patchOpts...); err != nil {
169-
log.Error(rerr, "Failed to patch config")
169+
log.Error(err, "Failed to patch config", "rerr", rerr)
170170
if rerr == nil {
171171
rerr = err
172172
}

controlplane/controllers/ck8scontrolplane_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ func (r *CK8sControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
144144
// Always attempt to update status.
145145
if updateErr := r.updateStatus(ctx, kcp, cluster); updateErr != nil {
146146
var connFailure *ck8s.RemoteClusterConnectionError
147-
if errors.As(err, &connFailure) {
148-
logger.Info("Could not connect to workload cluster to fetch status", "err", updateErr.Error())
147+
if errors.As(updateErr, &connFailure) {
148+
logger.Info("Could not connect to workload cluster to fetch status", "updateErr", updateErr.Error())
149149
} else {
150-
logger.Error(err, "Failed to update CK8sControlPlane Status")
150+
logger.Error(updateErr, "Failed to update CK8sControlPlane Status")
151151
err = kerrors.NewAggregate([]error{err, updateErr})
152152
}
153153
}
154154

155155
// Always attempt to Patch the CK8sControlPlane object and status after each reconciliation.
156156
if patchErr := patchCK8sControlPlane(ctx, patchHelper, kcp); patchErr != nil {
157-
logger.Error(err, "Failed to patch CK8sControlPlane")
157+
logger.Error(patchErr, "Failed to patch CK8sControlPlane")
158158
err = kerrors.NewAggregate([]error{err, patchErr})
159159
}
160160

0 commit comments

Comments
 (0)