Skip to content

🌱 Refine v1beta2 ControlPlaneHealthy condition #11438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
},
},
expectMachineConditions: []metav1.Condition{
Expand Down Expand Up @@ -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",
" * Control plane components: Waiting for GenericInfrastructureMachine to report spec.providerID",
},
},
expectMachineConditions: []metav1.Condition{
Expand Down
10 changes: 10 additions & 0 deletions controlplane/kubeadm/internal/workload_cluster_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
25 changes: 5 additions & 20 deletions controlplane/kubeadm/internal/workload_cluster_conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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: Node n1 does not exist",
},
expectedMachineV1Beta2Conditions: map[string][]metav1.Condition{
"m1": {
Expand Down