Skip to content

Commit f6404f3

Browse files
authored
Fix nil pointer when timeout is not set (#310)
Signed-off-by: Jian Qiu <[email protected]>
1 parent 550ac68 commit f6404f3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cluster/v1alpha1/helpers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (r *RolloutHandler[T]) getProgressiveClusters(rolloutStrategy RolloutStrate
167167
// Perform progressive rollOut for mandatory decision groups first, tolerating no failures
168168
if len(clusterGroups) > 0 {
169169
rolloutResult := progressivePerGroup(
170-
clusterGroups, intstr.FromInt(0), minSuccessTime, failureTimeout, currentClusterStatus,
170+
clusterGroups, intstr.FromInt32(0), minSuccessTime, failureTimeout, currentClusterStatus,
171171
)
172172
if len(rolloutResult.ClustersToRollout) > 0 || len(rolloutResult.ClustersTimeOut) > 0 {
173173
rolloutResult.ClustersRemoved = removedClusterStatus
@@ -223,7 +223,7 @@ func (r *RolloutHandler[T]) getProgressivePerGroupClusters(rolloutStrategy Rollo
223223

224224
// Perform progressive rollout per group for mandatory decision groups first, tolerating no failures
225225
if len(clusterGroups) > 0 {
226-
rolloutResult := progressivePerGroup(clusterGroups, intstr.FromInt(0), minSuccessTime, failureTimeout, currentClusterStatus)
226+
rolloutResult := progressivePerGroup(clusterGroups, intstr.FromInt32(0), minSuccessTime, failureTimeout, currentClusterStatus)
227227

228228
if len(rolloutResult.ClustersToRollout) > 0 || len(rolloutResult.ClustersTimeOut) > 0 {
229229
rolloutResult.ClustersRemoved = removedClusterStatus
@@ -585,7 +585,7 @@ func parseTimeout(timeoutStr string) (time.Duration, error) {
585585
}
586586

587587
func decisionGroupsToGroupKeys(decisionsGroup []MandatoryDecisionGroup) []clusterv1beta1.GroupKey {
588-
result := []clusterv1beta1.GroupKey{}
588+
var result []clusterv1beta1.GroupKey
589589
for _, d := range decisionsGroup {
590590
gk := clusterv1beta1.GroupKey{}
591591
// GroupName is considered first to select the decisionGroups then GroupIndex.
@@ -609,7 +609,7 @@ func minRecheckAfter(rolloutClusters []ClusterRolloutStatus, minSuccessTime time
609609
}
610610
}
611611
}
612-
if minSuccessTime != 0 && minSuccessTime < *minRecheckAfter {
612+
if minSuccessTime != 0 && (minRecheckAfter == nil || minSuccessTime < *minRecheckAfter) {
613613
minRecheckAfter = &minSuccessTime
614614
}
615615

cluster/v1alpha1/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,7 @@ func TestDecisionGroupsToGroupKeys(t *testing.T) {
24632463
{
24642464
name: "Empty MandatoryDecisionGroup",
24652465
input: []MandatoryDecisionGroup{},
2466-
expected: []clusterv1beta1.GroupKey{},
2466+
expected: nil,
24672467
},
24682468
}
24692469

0 commit comments

Comments
 (0)