Skip to content

Commit d8d4920

Browse files
authored
Merge pull request #11504 from fabriziopandini/refine-v1beta2-controlplanehealthy-and-etcdclusterhealthy
🌱 Refine KCP's Available, ControlPlaneComponentsHealthy, EtcdClusterHealthy v1beta2 conditions
2 parents 49eecd5 + 491fbcd commit d8d4920

File tree

5 files changed

+232
-44
lines changed

5 files changed

+232
-44
lines changed

controlplane/kubeadm/internal/controllers/controller_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,7 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
18521852
},
18531853
Spec: clusterv1.MachineSpec{
18541854
Version: ptr.To("v1.31.0"),
1855+
ProviderID: ptr.To("foo"),
18551856
InfrastructureRef: corev1.ObjectReference{Kind: "GenericInfrastructureMachine", APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", Name: "m1"},
18561857
},
18571858
}
@@ -2012,46 +2013,46 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
20122013
Status: metav1.ConditionUnknown,
20132014
Reason: controlplanev1.KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason,
20142015
Message: "* Machine machine1-test:\n" +
2015-
" * EtcdMemberHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
2016+
" * EtcdMemberHealthy: Waiting for a Node with spec.providerID foo to exist",
20162017
},
20172018
{
20182019
Type: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
20192020
Status: metav1.ConditionUnknown,
20202021
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
20212022
Message: "* Machine machine1-test:\n" +
2022-
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
2023+
" * Control plane components: Waiting for a Node with spec.providerID foo to exist",
20232024
},
20242025
},
20252026
expectMachineConditions: []metav1.Condition{
20262027
{
20272028
Type: controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition,
20282029
Status: metav1.ConditionUnknown,
20292030
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2030-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2031+
Message: "Waiting for a Node with spec.providerID foo to exist",
20312032
},
20322033
{
20332034
Type: controlplanev1.KubeadmControlPlaneMachineControllerManagerPodHealthyV1Beta2Condition,
20342035
Status: metav1.ConditionUnknown,
20352036
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2036-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2037+
Message: "Waiting for a Node with spec.providerID foo to exist",
20372038
},
20382039
{
20392040
Type: controlplanev1.KubeadmControlPlaneMachineSchedulerPodHealthyV1Beta2Condition,
20402041
Status: metav1.ConditionUnknown,
20412042
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2042-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2043+
Message: "Waiting for a Node with spec.providerID foo to exist",
20432044
},
20442045
{
20452046
Type: controlplanev1.KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition,
20462047
Status: metav1.ConditionUnknown,
20472048
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2048-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2049+
Message: "Waiting for a Node with spec.providerID foo to exist",
20492050
},
20502051
{
20512052
Type: controlplanev1.KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition,
20522053
Status: metav1.ConditionUnknown,
20532054
Reason: controlplanev1.KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason,
2054-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2055+
Message: "Waiting for a Node with spec.providerID foo to exist",
20552056
},
20562057
{
20572058
Type: clusterv1.MachineUpToDateV1Beta2Condition,
@@ -2089,46 +2090,46 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
20892090
Status: metav1.ConditionUnknown,
20902091
Reason: controlplanev1.KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason,
20912092
Message: "* Machine machine1-test:\n" +
2092-
" * EtcdMemberHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
2093+
" * EtcdMemberHealthy: Waiting for a Node with spec.providerID foo to exist",
20932094
},
20942095
{
20952096
Type: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
20962097
Status: metav1.ConditionUnknown,
20972098
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
20982099
Message: "* Machine machine1-test:\n" +
2099-
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
2100+
" * Control plane components: Waiting for a Node with spec.providerID foo to exist",
21002101
},
21012102
},
21022103
expectMachineConditions: []metav1.Condition{
21032104
{
21042105
Type: controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition,
21052106
Status: metav1.ConditionUnknown,
21062107
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2107-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2108+
Message: "Waiting for a Node with spec.providerID foo to exist",
21082109
},
21092110
{
21102111
Type: controlplanev1.KubeadmControlPlaneMachineControllerManagerPodHealthyV1Beta2Condition,
21112112
Status: metav1.ConditionUnknown,
21122113
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2113-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2114+
Message: "Waiting for a Node with spec.providerID foo to exist",
21142115
},
21152116
{
21162117
Type: controlplanev1.KubeadmControlPlaneMachineSchedulerPodHealthyV1Beta2Condition,
21172118
Status: metav1.ConditionUnknown,
21182119
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2119-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2120+
Message: "Waiting for a Node with spec.providerID foo to exist",
21202121
},
21212122
{
21222123
Type: controlplanev1.KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition,
21232124
Status: metav1.ConditionUnknown,
21242125
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
2125-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2126+
Message: "Waiting for a Node with spec.providerID foo to exist",
21262127
},
21272128
{
21282129
Type: controlplanev1.KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition,
21292130
Status: metav1.ConditionUnknown,
21302131
Reason: controlplanev1.KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason,
2131-
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
2132+
Message: "Waiting for a Node with spec.providerID foo to exist",
21322133
},
21332134
{
21342135
Type: clusterv1.MachineUpToDateV1Beta2Condition,

controlplane/kubeadm/internal/controllers/status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ func setAvailableCondition(_ context.Context, kcp *controlplanev1.KubeadmControl
587587
k8sControlPlaneNotHealthyButNotReportedYet := 0
588588

589589
for _, machine := range machines {
590+
// Ignore machines without a provider ID yet (which also implies infrastructure not ready).
591+
// Note: this avoids some noise when a new machine is provisioning; it is not possible to delay further
592+
// because the etcd member might join the cluster / control plane components might start even before
593+
// kubelet registers the node to the API server (e.g. in case kubelet has issues to register itself).
594+
if machine.Spec.ProviderID == nil {
595+
continue
596+
}
597+
590598
// if external etcd, only look at the status of the K8s control plane components on this machine.
591599
if !etcdIsManaged {
592600
if v1beta2conditions.IsTrue(machine, controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition) &&

0 commit comments

Comments
 (0)