Skip to content

Commit 5ab8d7e

Browse files
authored
[fix][operator] RayJob.Status.RayJobStatusInfo.EndTime nil deref error (#3742)
If users run the latest ray-operator code from master branch without updating their RayJob CRD, the operator panics from a nil pointer dereference error in `rayjob_controller.go`. `rayJob.Status.RayJobStatusInfo.EndTime` is nil when a RayJob's Job fails with RayJob CRD from v1.3.2. We check if `EndTime` is nil and return false from `checkTransitionGracePeriodAndUpdateStatusIfNeeded()` if so. Signed-off-by: David Xia <[email protected]>
1 parent 55c4efa commit 5ab8d7e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ray-operator/controllers/ray/rayjob_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,13 @@ func checkTransitionGracePeriodAndUpdateStatusIfNeeded(ctx context.Context, rayJ
935935
rayJobDeploymentGracePeriodTime = utils.DEFAULT_RAYJOB_DEPLOYMENT_STATUS_TRANSITION_GRACE_PERIOD_SECONDS
936936
}
937937

938+
// EndTime isn't nil when JobStatus is in a terminal state under normal conditions.
939+
// This check is a nil pointer dereference safeguard when older RayJob CRDs without the
940+
// RayJobStatusInfo field are used with newer versions of KubeRay operator.
941+
if rayJob.Status.RayJobStatusInfo.EndTime == nil {
942+
return false
943+
}
944+
938945
if time.Now().Before(rayJob.Status.RayJobStatusInfo.EndTime.Add(time.Duration(rayJobDeploymentGracePeriodTime) * time.Second)) {
939946
return false
940947
}

0 commit comments

Comments
 (0)