diff --git a/controlplane/kubeadm/internal/workload_cluster_conditions.go b/controlplane/kubeadm/internal/workload_cluster_conditions.go index f2e417f23b47..838fe8df5c20 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(" * %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..7d6eb13c6951 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", + " * 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", + " * 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", + " * 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", + " * 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", + " * Node n1 does not exist", }, expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{ "m1": {