Skip to content

Commit

Permalink
Fix log messages in Cluster set status code + some minor unit test fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer buringerst@vmware.com
  • Loading branch information
sbueringer committed Dec 30, 2024
1 parent b62b994 commit ad64bf6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/controllers/cluster/cluster_controller_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ func (s machinesConditionSetter) setMachinesCondition(ctx context.Context, clust
},
)
if err != nil {
log.Error(err, fmt.Sprintf("Failed to aggregate Machine's %s conditions", s.condition))
log.Error(err, fmt.Sprintf("Failed to aggregate Machine's %s conditions", s.machineAggregationCondition))
v1beta2conditions.Set(cluster, metav1.Condition{
Type: s.condition,
Status: metav1.ConditionUnknown,
Expand Down Expand Up @@ -835,7 +835,7 @@ func setRollingOutCondition(ctx context.Context, cluster *clusterv1.Cluster, con
},
)
if err != nil {
log.Error(err, "Failed to aggregate ControlPlane, MachinePool, MachineDeployment, MachineSet's RollingOut conditions")
log.Error(err, "Failed to aggregate ControlPlane, MachinePool, MachineDeployment's RollingOut conditions")
v1beta2conditions.Set(cluster, metav1.Condition{
Type: clusterv1.ClusterRollingOutV1Beta2Condition,
Status: metav1.ConditionUnknown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ func TestSetRollingOutCondition(t *testing.T) {
},
},
{
name: "cluster without controlplane, descendants report scaling up",
name: "cluster without controlplane, descendants report rolling out",
cluster: fakeCluster("c"),
machinePools: expv1.MachinePoolList{Items: []expv1.MachinePool{
*fakeMachinePool("mp1", v1beta2Condition{
Expand Down
6 changes: 3 additions & 3 deletions util/conditions/v1beta2/merge_strategies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestSummaryMessages(t *testing.T) {
d := &defaultMergeStrategy{
getPriorityFunc: GetDefaultMergePriorityFunc(),
}
t.Run("Drops info messages when status is not true", func(t *testing.T) {
t.Run("When status is not true, drop info messages", func(t *testing.T) {
g := NewWithT(t)

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

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

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

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

0 comments on commit ad64bf6

Please sign in to comment.