From ce2b44dabb77864dfbb417593e8409fb7f0cc6fe Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Wed, 21 Oct 2020 21:02:01 +0200 Subject: [PATCH] small improvements --- controlplane/kubeadm/controllers/remediation.go | 2 ++ controlplane/kubeadm/internal/workload_cluster_etcd.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/controlplane/kubeadm/controllers/remediation.go b/controlplane/kubeadm/controllers/remediation.go index 12915cda0f57..97032f47aa4d 100644 --- a/controlplane/kubeadm/controllers/remediation.go +++ b/controlplane/kubeadm/controllers/remediation.go @@ -106,6 +106,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileUnhealthyMachines(ctx context.C if c.IsEtcdManaged() { canSafelyRemediate, err := r.canSafelyRemoveEtcdMember(ctx, c, machineToBeRemediated) if err != nil { + conditions.MarkFalse(machineToBeRemediated, clusterv1.MachineOwnerRemediatedCondition, clusterv1.RemediationFailedReason, clusterv1.ConditionSeverityError, err.Error()) return ctrl.Result{}, err } @@ -121,6 +122,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileUnhealthyMachines(ctx context.C return ctrl.Result{}, errors.Wrapf(err, "failed to delete unhealthy machine %s", machineToBeRemediated.Name) } + logger.Info("Remediating unhealthy machine", "UnhealthyMachine", machineToBeRemediated.Name) conditions.MarkFalse(machineToBeRemediated, clusterv1.MachineOwnerRemediatedCondition, clusterv1.RemediationInProgressReason, clusterv1.ConditionSeverityWarning, "") return ctrl.Result{Requeue: true}, nil } diff --git a/controlplane/kubeadm/internal/workload_cluster_etcd.go b/controlplane/kubeadm/internal/workload_cluster_etcd.go index 1c3c8550edf0..ecefca1d556f 100644 --- a/controlplane/kubeadm/internal/workload_cluster_etcd.go +++ b/controlplane/kubeadm/internal/workload_cluster_etcd.go @@ -309,10 +309,11 @@ func (w *Workload) EtcdStatus(ctx context.Context) ([]EtcdMemberStatus, error) { return nil, errors.Wrap(err, "failed to list control plane nodes") } - etcdClient, err := w.etcdClientGenerator.forNodes(ctx, nodes.Items) + etcdClient, err := w.etcdClientGenerator.forLeader(ctx, nodes.Items) if err != nil { return nil, errors.Wrap(err, "failed to create etcd client") } + defer etcdClient.Close() members, err := etcdClient.Members(ctx) if err != nil {