Skip to content

Commit

Permalink
Fix nil pointer when timeout is not set (#310)
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 authored Jan 3, 2024
1 parent 550ac68 commit f6404f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cluster/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (r *RolloutHandler[T]) getProgressiveClusters(rolloutStrategy RolloutStrate
// Perform progressive rollOut for mandatory decision groups first, tolerating no failures
if len(clusterGroups) > 0 {
rolloutResult := progressivePerGroup(
clusterGroups, intstr.FromInt(0), minSuccessTime, failureTimeout, currentClusterStatus,
clusterGroups, intstr.FromInt32(0), minSuccessTime, failureTimeout, currentClusterStatus,
)
if len(rolloutResult.ClustersToRollout) > 0 || len(rolloutResult.ClustersTimeOut) > 0 {
rolloutResult.ClustersRemoved = removedClusterStatus
Expand Down Expand Up @@ -223,7 +223,7 @@ func (r *RolloutHandler[T]) getProgressivePerGroupClusters(rolloutStrategy Rollo

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

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

func decisionGroupsToGroupKeys(decisionsGroup []MandatoryDecisionGroup) []clusterv1beta1.GroupKey {
result := []clusterv1beta1.GroupKey{}
var result []clusterv1beta1.GroupKey
for _, d := range decisionsGroup {
gk := clusterv1beta1.GroupKey{}
// GroupName is considered first to select the decisionGroups then GroupIndex.
Expand All @@ -609,7 +609,7 @@ func minRecheckAfter(rolloutClusters []ClusterRolloutStatus, minSuccessTime time
}
}
}
if minSuccessTime != 0 && minSuccessTime < *minRecheckAfter {
if minSuccessTime != 0 && (minRecheckAfter == nil || minSuccessTime < *minRecheckAfter) {
minRecheckAfter = &minSuccessTime
}

Expand Down
2 changes: 1 addition & 1 deletion cluster/v1alpha1/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ func TestDecisionGroupsToGroupKeys(t *testing.T) {
{
name: "Empty MandatoryDecisionGroup",
input: []MandatoryDecisionGroup{},
expected: []clusterv1beta1.GroupKey{},
expected: nil,
},
}

Expand Down

0 comments on commit f6404f3

Please sign in to comment.