Skip to content

Commit

Permalink
Avoid possible nil pointer when CompletionTime not set (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored Apr 20, 2022
1 parent dff92c5 commit b8bd2e8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apis/flinkcluster/v1beta1/flinkcluster_types_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ func (j *JobStatus) ShouldRestart(spec *JobSpec) bool {
if j == nil || !j.IsFailed() || spec == nil {
return false
}
var restartEnabled = spec.RestartPolicy != nil && *spec.RestartPolicy == JobRestartPolicyFromSavepointOnFailure
var jobCompletionTime = j.CompletionTime.Time

restartEnabled := spec.RestartPolicy != nil && *spec.RestartPolicy == JobRestartPolicyFromSavepointOnFailure

var jobCompletionTime time.Time
if j.CompletionTime != nil {
jobCompletionTime = j.CompletionTime.Time
}

return restartEnabled && j.IsSavepointUpToDate(spec, jobCompletionTime)
}

Expand Down

0 comments on commit b8bd2e8

Please sign in to comment.