Skip to content

Commit ebcca99

Browse files
Refine v1beta2 ControlPlaneHealthy condition
1 parent a21faa0 commit ebcca99

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

controlplane/kubeadm/internal/workload_cluster_conditions.go

Lines changed: 10 additions & 0 deletions
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(" * %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

Lines changed: 5 additions & 20 deletions
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+
" * 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+
" * 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+
" * 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+
" * 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+
" * Node n1 does not exist",
965950
},
966951
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
967952
"m1": {

0 commit comments

Comments
 (0)