Skip to content

Commit f136ddf

Browse files
fabriziopandinisbueringer
authored andcommitted
Refine v1beta2 ControlPlaneHealthy condition
1 parent a21faa0 commit f136ddf

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

controlplane/kubeadm/internal/controllers/controller_test.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -2019,10 +2019,7 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
20192019
Status: metav1.ConditionUnknown,
20202020
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
20212021
Message: "* Machine machine1-test:\n" +
2022-
" * APIServerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
2023-
" * ControllerManagerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
2024-
" * SchedulerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
2025-
" * EtcdPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
2022+
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
20262023
},
20272024
},
20282025
expectMachineConditions: []metav1.Condition{
@@ -2099,10 +2096,7 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
20992096
Status: metav1.ConditionUnknown,
21002097
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
21012098
Message: "* Machine machine1-test:\n" +
2102-
" * APIServerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
2103-
" * ControllerManagerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
2104-
" * SchedulerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
2105-
" * EtcdPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
2099+
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
21062100
},
21072101
},
21082102
expectMachineConditions: []metav1.Condition{

controlplane/kubeadm/internal/workload_cluster_conditions.go

+10
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,12 @@ func aggregateV1Beta2ConditionsFromMachinesToKCP(input aggregateV1Beta2Condition
961961
for i := range input.controlPlane.Machines {
962962
machine := input.controlPlane.Machines[i]
963963
machineMessages := []string{}
964+
conditionCount := 0
965+
conditionMessages := sets.Set[string]{}
964966
for _, condition := range input.machineConditions {
965967
if machineCondition := v1beta2conditions.Get(machine, condition); machineCondition != nil {
968+
conditionCount++
969+
conditionMessages.Insert(machineCondition.Message)
966970
switch machineCondition.Status {
967971
case metav1.ConditionTrue:
968972
kcpMachinesWithInfo.Insert(machine.Name)
@@ -985,6 +989,12 @@ func aggregateV1Beta2ConditionsFromMachinesToKCP(input aggregateV1Beta2Condition
985989
}
986990

987991
if len(machineMessages) > 0 {
992+
if conditionCount > 1 && len(conditionMessages) == 1 {
993+
message := fmt.Sprintf(" * Control plane components: %s", conditionMessages.UnsortedList()[0])
994+
messageMap[message] = append(messageMap[message], machine.Name)
995+
continue
996+
}
997+
988998
message := strings.Join(machineMessages, "\n")
989999
messageMap[message] = append(messageMap[message], machine.Name)
9901000
}

controlplane/kubeadm/internal/workload_cluster_conditions_test.go

+5-20
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,7 @@ func TestUpdateStaticPodConditions(t *testing.T) {
804804
Status: metav1.ConditionUnknown,
805805
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
806806
Message: "* Machine m1:\n" +
807-
" * APIServerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" +
808-
" * ControllerManagerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" +
809-
" * SchedulerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" +
810-
" * EtcdPodHealthy: Waiting for GenericInfraMachine to report spec.providerID",
807+
" * Control plane components: Waiting for GenericInfraMachine to report spec.providerID",
811808
},
812809
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
813810
"m1": {
@@ -837,10 +834,7 @@ func TestUpdateStaticPodConditions(t *testing.T) {
837834
Status: metav1.ConditionUnknown,
838835
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
839836
Message: "* Machine m1:\n" +
840-
" * APIServerPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist\n" +
841-
" * ControllerManagerPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist\n" +
842-
" * SchedulerPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist\n" +
843-
" * EtcdPodHealthy: Waiting for a Node with spec.providerID dummy-provider-id to exist",
837+
" * Control plane components: Waiting for a Node with spec.providerID dummy-provider-id to exist",
844838
},
845839
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
846840
"m1": {
@@ -891,10 +885,7 @@ func TestUpdateStaticPodConditions(t *testing.T) {
891885
Status: metav1.ConditionUnknown,
892886
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
893887
Message: "* Machine m1:\n" +
894-
" * APIServerPodHealthy: Node n1 is unreachable\n" +
895-
" * ControllerManagerPodHealthy: Node n1 is unreachable\n" +
896-
" * SchedulerPodHealthy: Node n1 is unreachable\n" +
897-
" * EtcdPodHealthy: Node n1 is unreachable",
888+
" * Control plane components: Node n1 is unreachable",
898889
},
899890
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
900891
"m1": {
@@ -922,10 +913,7 @@ func TestUpdateStaticPodConditions(t *testing.T) {
922913
Status: metav1.ConditionUnknown,
923914
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
924915
Message: "* Machine m1:\n" +
925-
" * APIServerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" +
926-
" * ControllerManagerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" +
927-
" * SchedulerPodHealthy: Waiting for GenericInfraMachine to report spec.providerID\n" +
928-
" * EtcdPodHealthy: Waiting for GenericInfraMachine to report spec.providerID",
916+
" * Control plane components: Waiting for GenericInfraMachine to report spec.providerID",
929917
},
930918
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
931919
"m1": {
@@ -958,10 +946,7 @@ func TestUpdateStaticPodConditions(t *testing.T) {
958946
Status: metav1.ConditionUnknown,
959947
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
960948
Message: "* Machine m1:\n" +
961-
" * APIServerPodHealthy: Node n1 does not exist\n" +
962-
" * ControllerManagerPodHealthy: Node n1 does not exist\n" +
963-
" * SchedulerPodHealthy: Node n1 does not exist\n" +
964-
" * EtcdPodHealthy: Node n1 does not exist",
949+
" * Control plane components: Node n1 does not exist",
965950
},
966951
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
967952
"m1": {

0 commit comments

Comments
 (0)