diff --git a/internal/controllers/cluster/cluster_controller_status.go b/internal/controllers/cluster/cluster_controller_status.go index eb0892624731..5b5c1e9b08ce 100644 --- a/internal/controllers/cluster/cluster_controller_status.go +++ b/internal/controllers/cluster/cluster_controller_status.go @@ -714,7 +714,7 @@ func (s machinesConditionSetter) setMachinesCondition(ctx context.Context, clust }, ) if err != nil { - log.Error(err, "Failed to aggregate Machine's Ready conditions") + log.Error(err, fmt.Sprintf("Failed to aggregate Machine's %s conditions", s.condition)) v1beta2conditions.Set(cluster, metav1.Condition{ Type: s.condition, Status: metav1.ConditionUnknown, diff --git a/internal/controllers/cluster/cluster_controller_status_test.go b/internal/controllers/cluster/cluster_controller_status_test.go index c19ff13763e0..362eef6368b3 100644 --- a/internal/controllers/cluster/cluster_controller_status_test.go +++ b/internal/controllers/cluster/cluster_controller_status_test.go @@ -1037,7 +1037,7 @@ func TestSetControlPlaneMachinesUpToDateCondition(t *testing.T) { name: "One machine up-to-date", cluster: fakeCluster("c"), machines: []*clusterv1.Machine{ - fakeMachine("up-to-date-1", v1beta2Condition(metav1.Condition{ + fakeMachine("up-to-date-1", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionTrue, Reason: "some-reason-1", @@ -1055,7 +1055,7 @@ func TestSetControlPlaneMachinesUpToDateCondition(t *testing.T) { name: "One machine unknown", cluster: fakeCluster("c"), machines: []*clusterv1.Machine{ - fakeMachine("unknown-1", v1beta2Condition(metav1.Condition{ + fakeMachine("unknown-1", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionUnknown, Reason: "some-unknown-reason-1", @@ -1074,7 +1074,7 @@ func TestSetControlPlaneMachinesUpToDateCondition(t *testing.T) { name: "One machine not up-to-date", cluster: fakeCluster("c"), machines: []*clusterv1.Machine{ - fakeMachine("not-up-to-date-machine-1", v1beta2Condition(metav1.Condition{ + fakeMachine("not-up-to-date-machine-1", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse, Reason: "some-not-up-to-date-reason", @@ -1093,8 +1093,8 @@ func TestSetControlPlaneMachinesUpToDateCondition(t *testing.T) { name: "One machine without up-to-date condition, one new Machines without up-to-date condition", cluster: fakeCluster("c"), machines: []*clusterv1.Machine{ - fakeMachine("no-condition-machine-1"), - fakeMachine("no-condition-machine-2-new", creationTimestamp{Time: time.Now().Add(-5 * time.Second)}), // ignored because it's new + fakeMachine("no-condition-machine-1", controlPlane(true)), + fakeMachine("no-condition-machine-2-new", controlPlane(true), creationTimestamp{Time: time.Now().Add(-5 * time.Second)}), // ignored because it's new }, getDescendantsSucceeded: true, expectCondition: metav1.Condition{ @@ -1108,30 +1108,30 @@ func TestSetControlPlaneMachinesUpToDateCondition(t *testing.T) { name: "Two machines not up-to-date, two up-to-date, two not reported", cluster: fakeCluster("c"), machines: []*clusterv1.Machine{ - fakeMachine("up-to-date-1", v1beta2Condition(metav1.Condition{ + fakeMachine("up-to-date-1", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionTrue, Reason: "TestUpToDate", })), - fakeMachine("up-to-date-2", v1beta2Condition(metav1.Condition{ + fakeMachine("up-to-date-2", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionTrue, Reason: "TestUpToDate", })), - fakeMachine("not-up-to-date-machine-1", v1beta2Condition(metav1.Condition{ + fakeMachine("not-up-to-date-machine-1", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse, Reason: "TestNotUpToDate", Message: "This is not up-to-date message", })), - fakeMachine("not-up-to-date-machine-2", v1beta2Condition(metav1.Condition{ + fakeMachine("not-up-to-date-machine-2", controlPlane(true), v1beta2Condition(metav1.Condition{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse, Reason: "TestNotUpToDate", Message: "This is not up-to-date message", })), - fakeMachine("no-condition-machine-1"), - fakeMachine("no-condition-machine-2"), + fakeMachine("no-condition-machine-1", controlPlane(true)), + fakeMachine("no-condition-machine-2", controlPlane(true)), }, getDescendantsSucceeded: true, expectCondition: metav1.Condition{