Skip to content

Commit

Permalink
Refine KCP's Available, ControlPlaneComponentsHealthy, EtcdClusterHea…
Browse files Browse the repository at this point in the history
…lthy v1beta2 conditions
  • Loading branch information
fabriziopandini committed Nov 29, 2024
1 parent 93b4aac commit 491fbcd
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 44 deletions.
29 changes: 15 additions & 14 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,7 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
},
Spec: clusterv1.MachineSpec{
Version: ptr.To("v1.31.0"),
ProviderID: ptr.To("foo"),
InfrastructureRef: corev1.ObjectReference{Kind: "GenericInfrastructureMachine", APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", Name: "m1"},
},
}
Expand Down Expand Up @@ -2012,46 +2013,46 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * EtcdMemberHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
" * EtcdMemberHealthy: Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
" * Control plane components: Waiting for a Node with spec.providerID foo to exist",
},
},
expectMachineConditions: []metav1.Condition{
{
Type: controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineControllerManagerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineSchedulerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: clusterv1.MachineUpToDateV1Beta2Condition,
Expand Down Expand Up @@ -2089,46 +2090,46 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * EtcdMemberHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
" * EtcdMemberHealthy: Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
" * Control plane components: Waiting for a Node with spec.providerID foo to exist",
},
},
expectMachineConditions: []metav1.Condition{
{
Type: controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineControllerManagerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineSchedulerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason,
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
Message: "Waiting for a Node with spec.providerID foo to exist",
},
{
Type: clusterv1.MachineUpToDateV1Beta2Condition,
Expand Down
8 changes: 8 additions & 0 deletions controlplane/kubeadm/internal/controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,14 @@ func setAvailableCondition(_ context.Context, kcp *controlplanev1.KubeadmControl
k8sControlPlaneNotHealthyButNotReportedYet := 0

for _, machine := range machines {
// Ignore machines without a provider ID yet (which also implies infrastructure not ready).
// Note: this avoids some noise when a new machine is provisioning; it is not possible to delay further
// because the etcd member might join the cluster / control plane components might start even before
// kubelet registers the node to the API server (e.g. in case kubelet has issues to register itself).
if machine.Spec.ProviderID == nil {
continue
}

// if external etcd, only look at the status of the K8s control plane components on this machine.
if !etcdIsManaged {
if v1beta2conditions.IsTrue(machine, controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition) &&
Expand Down
Loading

0 comments on commit 491fbcd

Please sign in to comment.