Skip to content

Commit d38c904

Browse files
authored
fix NPE introduce on kubeflow#1280 (kubeflow#1325)
1 parent 85b549e commit d38c904

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pkg/controller/sparkapplication/controller.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,13 @@ func (c *Controller) getAndUpdateExecutorState(app *v1beta2.SparkApplication) er
376376
if !exists || newState != oldState {
377377
if newState == v1beta2.ExecutorFailedState {
378378
execContainerState := getExecutorContainerTerminatedState(pod.Status)
379-
c.recordExecutorEvent(app, newState, pod.Name, execContainerState.ExitCode, execContainerState.Reason)
379+
if execContainerState != nil {
380+
c.recordExecutorEvent(app, newState, pod.Name, execContainerState.ExitCode, execContainerState.Reason)
381+
} else {
382+
// If we can't find the container state,
383+
// we need to set the exitCode and the Reason to unambiguous values.
384+
c.recordExecutorEvent(app, newState, pod.Name, -1, "Unknown (Container not Found)")
385+
}
380386
} else {
381387
c.recordExecutorEvent(app, newState, pod.Name)
382388
}

pkg/controller/sparkapplication/sparkapp_util.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ func getDriverContainerTerminatedState(podStatus apiv1.PodStatus) *apiv1.Contain
138138
}
139139

140140
func getExecutorContainerTerminatedState(podStatus apiv1.PodStatus) *apiv1.ContainerStateTerminated {
141-
return getContainerTerminatedState(config.SparkExecutorContainerName, podStatus)
141+
state := getContainerTerminatedState(config.Spark3DefaultExecutorContainerName, podStatus)
142+
if state == nil {
143+
state = getContainerTerminatedState(config.SparkExecutorContainerName, podStatus)
144+
}
145+
return state
142146
}
143147

144148
func getContainerTerminatedState(name string, podStatus apiv1.PodStatus) *apiv1.ContainerStateTerminated {

0 commit comments

Comments
 (0)