Skip to content

Commit ad64bf6

Browse files
committed
Fix log messages in Cluster set status code + some minor unit test fixes
Signed-off-by: Stefan Büringer [email protected]
1 parent b62b994 commit ad64bf6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

internal/controllers/cluster/cluster_controller_status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ func (s machinesConditionSetter) setMachinesCondition(ctx context.Context, clust
715715
},
716716
)
717717
if err != nil {
718-
log.Error(err, fmt.Sprintf("Failed to aggregate Machine's %s conditions", s.condition))
718+
log.Error(err, fmt.Sprintf("Failed to aggregate Machine's %s conditions", s.machineAggregationCondition))
719719
v1beta2conditions.Set(cluster, metav1.Condition{
720720
Type: s.condition,
721721
Status: metav1.ConditionUnknown,
@@ -835,7 +835,7 @@ func setRollingOutCondition(ctx context.Context, cluster *clusterv1.Cluster, con
835835
},
836836
)
837837
if err != nil {
838-
log.Error(err, "Failed to aggregate ControlPlane, MachinePool, MachineDeployment, MachineSet's RollingOut conditions")
838+
log.Error(err, "Failed to aggregate ControlPlane, MachinePool, MachineDeployment's RollingOut conditions")
839839
v1beta2conditions.Set(cluster, metav1.Condition{
840840
Type: clusterv1.ClusterRollingOutV1Beta2Condition,
841841
Status: metav1.ConditionUnknown,

internal/controllers/cluster/cluster_controller_status_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ func TestSetRollingOutCondition(t *testing.T) {
14721472
},
14731473
},
14741474
{
1475-
name: "cluster without controlplane, descendants report scaling up",
1475+
name: "cluster without controlplane, descendants report rolling out",
14761476
cluster: fakeCluster("c"),
14771477
machinePools: expv1.MachinePoolList{Items: []expv1.MachinePool{
14781478
*fakeMachinePool("mp1", v1beta2Condition{

util/conditions/v1beta2/merge_strategies_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestSummaryMessages(t *testing.T) {
9393
d := &defaultMergeStrategy{
9494
getPriorityFunc: GetDefaultMergePriorityFunc(),
9595
}
96-
t.Run("Drops info messages when status is not true", func(t *testing.T) {
96+
t.Run("When status is not true, drop info messages", func(t *testing.T) {
9797
g := NewWithT(t)
9898

9999
conditions := []ConditionWithOwnerInfo{
@@ -108,9 +108,10 @@ func TestSummaryMessages(t *testing.T) {
108108

109109
g.Expect(message).To(Equal("* A: Message-A\n" +
110110
"* B: Message-B\n" +
111+
// Info message of true condition C was dropped
111112
"* D: Reason-D")) // False conditions without messages must show the reason
112113
})
113-
t.Run("When status is not true, surface only not empty messages", func(t *testing.T) {
114+
t.Run("When status is true, surface only not empty messages", func(t *testing.T) {
114115
g := NewWithT(t)
115116

116117
conditions := []ConditionWithOwnerInfo{
@@ -129,7 +130,6 @@ func TestSummaryMessages(t *testing.T) {
129130
g := NewWithT(t)
130131

131132
conditions := []ConditionWithOwnerInfo{
132-
// NOTE: objects are intentionally not in order so we can validate they are sorted by name
133133
{OwnerResource: ConditionOwnerInfo{Kind: "MachineDeployment", Name: "obj01"}, Condition: metav1.Condition{Type: "A", Reason: "Reason-A", Message: "Message-A", Status: metav1.ConditionTrue}},
134134
{OwnerResource: ConditionOwnerInfo{Kind: "MachineDeployment", Name: "obj01"}, Condition: metav1.Condition{Type: "B", Reason: "Reason-B", Message: "* Message-B", Status: metav1.ConditionTrue}},
135135
{OwnerResource: ConditionOwnerInfo{Kind: "MachineDeployment", Name: "obj01"}, Condition: metav1.Condition{Type: "C", Reason: "Reason-C", Message: "* Message-C1\n* Message-C2", Status: metav1.ConditionTrue}},

0 commit comments

Comments
 (0)