diff --git a/controlplane/kubeadm/internal/controllers/controller_test.go b/controlplane/kubeadm/internal/controllers/controller_test.go index 53bbb9f3e71c..7661c9a52a86 100644 --- a/controlplane/kubeadm/internal/controllers/controller_test.go +++ b/controlplane/kubeadm/internal/controllers/controller_test.go @@ -2019,10 +2019,7 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine machine1-test:\n" + - " * APIServerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" + - " * ControllerManagerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" + - " * SchedulerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" + - " * EtcdPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID", + " * Waiting for GenericInfrastructureMachine to report spec.providerID", }, }, expectMachineConditions: []metav1.Condition{ @@ -2099,10 +2096,7 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine machine1-test:\n" + - " * APIServerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" + - " * ControllerManagerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" + - " * SchedulerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" + - " * EtcdPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID", + " * Waiting for GenericInfrastructureMachine to report spec.providerID", }, }, expectMachineConditions: []metav1.Condition{ diff --git a/controlplane/kubeadm/internal/workload_cluster_conditions.go b/controlplane/kubeadm/internal/workload_cluster_conditions.go index f2e417f23b47..20c168ccd509 100644 --- a/controlplane/kubeadm/internal/workload_cluster_conditions.go +++ b/controlplane/kubeadm/internal/workload_cluster_conditions.go @@ -961,8 +961,12 @@ func aggregateV1Beta2ConditionsFromMachinesToKCP(input aggregateV1Beta2Condition for i := range input.controlPlane.Machines { machine := input.controlPlane.Machines[i] machineMessages := []string{} + conditionCount := 0 + conditionMessages := sets.Set[string]{} for _, condition := range input.machineConditions { if machineCondition := v1beta2conditions.Get(machine, condition); machineCondition != nil { + conditionCount++ + conditionMessages.Insert(machineCondition.Message) switch machineCondition.Status { case metav1.ConditionTrue: kcpMachinesWithInfo.Insert(machine.Name) @@ -985,6 +989,12 @@ func aggregateV1Beta2ConditionsFromMachinesToKCP(input aggregateV1Beta2Condition } if len(machineMessages) > 0 { + if conditionCount > 1 && len(conditionMessages) == 1 { + message := fmt.Sprintf(" * Control plane components: %s", conditionMessages.UnsortedList()[0]) + messageMap[message] = append(messageMap[message], machine.Name) + continue + } + message := strings.Join(machineMessages, "\n") messageMap[message] = append(messageMap[message], machine.Name) } diff --git a/controlplane/kubeadm/internal/workload_cluster_conditions_test.go b/controlplane/kubeadm/internal/workload_cluster_conditions_test.go index 1e4a70ab2b71..04dd07b6e2b4 100644 --- a/controlplane/kubeadm/internal/workload_cluster_conditions_test.go +++ b/controlplane/kubeadm/internal/workload_cluster_conditions_test.go @@ -804,10 +804,7 @@ func TestUpdateStaticPodConditions(t *testing.T) { Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine m1:\n" + - " * APIServerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" + - " * ControllerManagerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" + - " * SchedulerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" + - " * EtcdPodHealthy: Waiting for GenericInfraMachine to report spec.providerID", + " * Control plane components: Waiting for GenericInfraMachine to report spec.providerID", }, expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{ "m1": { @@ -837,10 +834,7 @@ func TestUpdateStaticPodConditions(t *testing.T) { Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine m1:\n" + - " * APIServerPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist\n" + - " * ControllerManagerPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist\n" + - " * SchedulerPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist\n" + - " * EtcdPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist", + " * Control plane components: Waiting for a Node with spec.providerID dummy-provider-id to exist", }, expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{ "m1": { @@ -891,10 +885,7 @@ func TestUpdateStaticPodConditions(t *testing.T) { Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine m1:\n" + - " * APIServerPodHealthy: Node n1 is unreachable\n" + - " * ControllerManagerPodHealthy: Node n1 is unreachable\n" + - " * SchedulerPodHealthy: Node n1 is unreachable\n" + - " * EtcdPodHealthy: Node n1 is unreachable", + " * Control plane components: Node n1 is unreachable", }, expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{ "m1": { @@ -922,10 +913,7 @@ func TestUpdateStaticPodConditions(t *testing.T) { Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine m1:\n" + - " * APIServerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" + - " * ControllerManagerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" + - " * SchedulerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" + - " * EtcdPodHealthy: Waiting for GenericInfraMachine to report spec.providerID", + " * Control plane components: Waiting for GenericInfraMachine to report spec.providerID", }, expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{ "m1": { @@ -958,10 +946,7 @@ func TestUpdateStaticPodConditions(t *testing.T) { Status: metav1.ConditionUnknown, Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason, Message: "* Machine m1:\n" + - " * APIServerPodHealthy: Node n1 does not exist\n" + - " * ControllerManagerPodHealthy: Node n1 does not exist\n" + - " * SchedulerPodHealthy: Node n1 does not exist\n" + - " * EtcdPodHealthy: Node n1 does not exist", + " * Control plane components: gNode n1 does not exist", }, expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{ "m1": {