Skip to content

Commit 0a5c2bd

Browse files
More feedback
1 parent 6ec38a2 commit 0a5c2bd

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,21 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
214214

215215
defer func() {
216216
// Always attempt to update status.
217-
var connFailure *internal.RemoteClusterConnectionError
218217
if err := r.updateStatus(ctx, controlPlane); err != nil {
218+
var connFailure *internal.RemoteClusterConnectionError
219219
if errors.As(err, &connFailure) {
220220
log.Error(err, "Could not connect to workload cluster to fetch status")
221221
} else {
222-
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrap(err, "Failed to update KubeadmControlPlane status")})
222+
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrap(err, "failed to update KubeadmControlPlane status")})
223223
}
224224
}
225225

226226
if err := r.updateV1Beta1Status(ctx, controlPlane); err != nil {
227+
var connFailure *internal.RemoteClusterConnectionError
227228
if errors.As(err, &connFailure) {
228-
log.Error(err, "Could not connect to workload cluster to fetch status")
229+
log.Error(err, "Could not connect to workload cluster to fetch deprecated v1beta1 status")
229230
} else {
230-
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrap(err, "Failed to update KubeadmControlPlane deprecated v1beta1 status")})
231+
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrap(err, "failed to update KubeadmControlPlane deprecated v1beta1 status")})
231232
}
232233
}
233234

@@ -237,7 +238,7 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
237238
patchOpts = append(patchOpts, patch.WithStatusObservedGeneration{})
238239
}
239240
if err := patchKubeadmControlPlane(ctx, patchHelper, kcp, patchOpts...); err != nil {
240-
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrap(err, "Failed to patch KubeadmControlPlane")})
241+
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrap(err, "failed to patch KubeadmControlPlane")})
241242
}
242243

243244
// Only requeue if there is no error, Requeue or RequeueAfter and the object does not have a deletion timestamp.

controlplane/kubeadm/internal/controllers/status.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/pkg/errors"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28+
kerrors "k8s.io/apimachinery/pkg/util/errors"
2829
"k8s.io/apimachinery/pkg/util/sets"
2930
"k8s.io/utils/ptr"
3031
ctrl "sigs.k8s.io/controller-runtime"
@@ -129,8 +130,9 @@ func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, contro
129130
controlPlane.KCP.Status.Version = lowestVersion
130131
}
131132

133+
allErrors := []error{}
132134
if err := setControlPlaneInitialized(ctx, controlPlane); err != nil {
133-
return err
135+
allErrors = append(allErrors, err)
134136
}
135137
setReplicas(ctx, controlPlane.KCP, controlPlane.Machines)
136138
setInitializedCondition(ctx, controlPlane.KCP)
@@ -142,7 +144,10 @@ func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, contro
142144
setRemediatingCondition(ctx, controlPlane.KCP, controlPlane.MachinesToBeRemediatedByKCP(), controlPlane.UnhealthyMachines())
143145
setDeletingCondition(ctx, controlPlane.KCP, controlPlane.DeletingReason, controlPlane.DeletingMessage)
144146
setAvailableCondition(ctx, controlPlane.KCP, controlPlane.IsEtcdManaged(), controlPlane.EtcdMembers, controlPlane.EtcdMembersAndMachinesAreMatching, controlPlane.Machines)
145-
return setLastRemediation(ctx, controlPlane)
147+
if err := setLastRemediation(ctx, controlPlane); err != nil {
148+
allErrors = append(allErrors, err)
149+
}
150+
return kerrors.NewAggregate(allErrors)
146151
}
147152

148153
// setControlPlaneInitialized surface control plane initialized when it is possible to check that the Kubeadm config exists in the workload cluster;

0 commit comments

Comments
 (0)