From b8bd2e852ad8fbaa6018c4f1c208589426af3f32 Mon Sep 17 00:00:00 2001 From: Filipe Regadas Date: Wed, 20 Apr 2022 18:10:17 +0100 Subject: [PATCH] Avoid possible nil pointer when CompletionTime not set (#377) --- apis/flinkcluster/v1beta1/flinkcluster_types_util.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apis/flinkcluster/v1beta1/flinkcluster_types_util.go b/apis/flinkcluster/v1beta1/flinkcluster_types_util.go index b5b496ef..db217c51 100644 --- a/apis/flinkcluster/v1beta1/flinkcluster_types_util.go +++ b/apis/flinkcluster/v1beta1/flinkcluster_types_util.go @@ -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) }