Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit e5441e0

Browse files
authored
Merge pull request #242 from accepting/opt
Patch kubeadmconfig objects only if no error occurs during reconciliation
2 parents c94ead1 + f9521e7 commit e5441e0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

controllers/kubeadmconfig_controller.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,11 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
151151
if err != nil {
152152
return ctrl.Result{}, err
153153
}
154-
// Always attempt to Patch the KubeadmConfig object and status after each reconciliation.
154+
// Attempt to Patch the KubeadmConfig object and status after each reconciliation if no error occurs.
155155
defer func() {
156-
if err := patchHelper.Patch(ctx, config); err != nil {
157-
log.Error(err, "failed to patch config")
158-
if rerr == nil {
159-
rerr = err
156+
if rerr == nil {
157+
if rerr = patchHelper.Patch(ctx, config); rerr != nil {
158+
log.Error(rerr, "failed to patch config")
160159
}
161160
}
162161
}()

0 commit comments

Comments
 (0)