Skip to content

Commit 6558328

Browse files
authored
Merge pull request #11952 from cahillsf/modify-calling-agg-cluster-conditions
🐛 Modify calling agg cluster conditions
2 parents 38ac239 + 5b57931 commit 6558328

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

internal/controllers/cluster/cluster_controller_status.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -791,15 +791,6 @@ func setRollingOutCondition(ctx context.Context, cluster *clusterv1.Cluster, con
791791
return
792792
}
793793

794-
if controlPlane == nil && len(machinePools.Items)+len(machineDeployments.Items) == 0 {
795-
v1beta2conditions.Set(cluster, metav1.Condition{
796-
Type: clusterv1.ClusterRollingOutV1Beta2Condition,
797-
Status: metav1.ConditionFalse,
798-
Reason: clusterv1.ClusterNotRollingOutV1Beta2Reason,
799-
})
800-
return
801-
}
802-
803794
ws := make([]aggregationWrapper, 0, len(machinePools.Items)+len(machineDeployments.Items)+1)
804795
if controlPlane != nil {
805796
// control plane is considered only if it is reporting the condition (the contract does not require conditions to be reported)
@@ -815,6 +806,15 @@ func setRollingOutCondition(ctx context.Context, cluster *clusterv1.Cluster, con
815806
ws = append(ws, aggregationWrapper{md: &md})
816807
}
817808

809+
if len(ws) == 0 {
810+
v1beta2conditions.Set(cluster, metav1.Condition{
811+
Type: clusterv1.ClusterRollingOutV1Beta2Condition,
812+
Status: metav1.ConditionFalse,
813+
Reason: clusterv1.ClusterNotRollingOutV1Beta2Reason,
814+
})
815+
return
816+
}
817+
818818
rollingOutCondition, err := v1beta2conditions.NewAggregateCondition(
819819
ws, clusterv1.RollingOutV1Beta2Condition,
820820
v1beta2conditions.TargetConditionType(clusterv1.ClusterRollingOutV1Beta2Condition),
@@ -862,15 +862,6 @@ func setScalingUpCondition(ctx context.Context, cluster *clusterv1.Cluster, cont
862862
return
863863
}
864864

865-
if controlPlane == nil && len(machinePools.Items)+len(machineDeployments.Items) == 0 {
866-
v1beta2conditions.Set(cluster, metav1.Condition{
867-
Type: clusterv1.ClusterScalingUpV1Beta2Condition,
868-
Status: metav1.ConditionFalse,
869-
Reason: clusterv1.ClusterNotScalingUpV1Beta2Reason,
870-
})
871-
return
872-
}
873-
874865
ws := make([]aggregationWrapper, 0, len(machinePools.Items)+len(machineDeployments.Items)+1)
875866
if controlPlane != nil {
876867
// control plane is considered only if it is reporting the condition (the contract does not require conditions to be reported)
@@ -892,6 +883,15 @@ func setScalingUpCondition(ctx context.Context, cluster *clusterv1.Cluster, cont
892883
ws = append(ws, aggregationWrapper{ms: &ms})
893884
}
894885

886+
if len(ws) == 0 {
887+
v1beta2conditions.Set(cluster, metav1.Condition{
888+
Type: clusterv1.ClusterScalingUpV1Beta2Condition,
889+
Status: metav1.ConditionFalse,
890+
Reason: clusterv1.ClusterNotScalingUpV1Beta2Reason,
891+
})
892+
return
893+
}
894+
895895
scalingUpCondition, err := v1beta2conditions.NewAggregateCondition(
896896
ws, clusterv1.ScalingUpV1Beta2Condition,
897897
v1beta2conditions.TargetConditionType(clusterv1.ClusterScalingUpV1Beta2Condition),
@@ -939,15 +939,6 @@ func setScalingDownCondition(ctx context.Context, cluster *clusterv1.Cluster, co
939939
return
940940
}
941941

942-
if controlPlane == nil && len(machinePools.Items)+len(machineDeployments.Items) == 0 {
943-
v1beta2conditions.Set(cluster, metav1.Condition{
944-
Type: clusterv1.ClusterScalingDownV1Beta2Condition,
945-
Status: metav1.ConditionFalse,
946-
Reason: clusterv1.ClusterNotScalingDownV1Beta2Reason,
947-
})
948-
return
949-
}
950-
951942
ws := make([]aggregationWrapper, 0, len(machinePools.Items)+len(machineDeployments.Items)+1)
952943
if controlPlane != nil {
953944
// control plane is considered only if it is reporting the condition (the contract does not require conditions to be reported)
@@ -969,6 +960,15 @@ func setScalingDownCondition(ctx context.Context, cluster *clusterv1.Cluster, co
969960
ws = append(ws, aggregationWrapper{ms: &ms})
970961
}
971962

963+
if len(ws) == 0 {
964+
v1beta2conditions.Set(cluster, metav1.Condition{
965+
Type: clusterv1.ClusterScalingDownV1Beta2Condition,
966+
Status: metav1.ConditionFalse,
967+
Reason: clusterv1.ClusterNotScalingDownV1Beta2Reason,
968+
})
969+
return
970+
}
971+
972972
scalingDownCondition, err := v1beta2conditions.NewAggregateCondition(
973973
ws, clusterv1.ScalingDownV1Beta2Condition,
974974
v1beta2conditions.TargetConditionType(clusterv1.ClusterScalingDownV1Beta2Condition),

util/conditions/v1beta2/aggregate_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ func TestAggregate(t *testing.T) {
6969
wantErr: false,
7070
},
7171
{
72-
name: "Error if negative polarity conditions are misconfigured",
73-
conditions: [][]metav1.Condition{},
72+
name: "Error if negative polarity conditions are misconfigured",
73+
conditions: [][]metav1.Condition{
74+
{{Type: clusterv1.ScalingUpV1Beta2Condition, Status: metav1.ConditionTrue, Reason: "Reason-1", Message: "Message-1"}},
75+
},
7476
conditionType: clusterv1.ScalingUpV1Beta2Condition,
7577
options: []AggregateOption{NegativePolarityConditionTypes{"foo"}}, // NegativePolarityConditionTypes if set must equal source condition
7678
want: nil,

0 commit comments

Comments
 (0)