Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
feat(job): Add a check to avoid null pointer exception (#178)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
gaocegege authored Nov 26, 2021
1 parent 26a6cec commit 1edc535
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/controller.v1/common/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ func (jc *JobController) CleanupJob(runPolicy *apiv1.RunPolicy, jobStatus apiv1.
return nil
}
duration := time.Second * time.Duration(*ttl)
// todo: Is the jobStatus.CompletionTime maybe nil ?
if jobStatus.CompletionTime == nil {
return fmt.Errorf("job completion time is nil, cannot cleanup")
}
finishTime := jobStatus.CompletionTime
expireTime := finishTime.Add(duration)
if currentTime.After(expireTime) {
Expand Down

0 comments on commit 1edc535

Please sign in to comment.