Skip to content

Commit

Permalink
fix NPE introduce on kubeflow#1280 (kubeflow#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImpSy authored Aug 20, 2021
1 parent 3dbc9c6 commit 611c384
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pkg/controller/sparkapplication/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,13 @@ func (c *Controller) getAndUpdateExecutorState(app *v1beta2.SparkApplication) er
if !exists || newState != oldState {
if newState == v1beta2.ExecutorFailedState {
execContainerState := getExecutorContainerTerminatedState(pod.Status)
c.recordExecutorEvent(app, newState, pod.Name, execContainerState.ExitCode, execContainerState.Reason)
if execContainerState != nil {
c.recordExecutorEvent(app, newState, pod.Name, execContainerState.ExitCode, execContainerState.Reason)
} else {
// If we can't find the container state,
// we need to set the exitCode and the Reason to unambiguous values.
c.recordExecutorEvent(app, newState, pod.Name, -1, "Unknown (Container not Found)")
}
} else {
c.recordExecutorEvent(app, newState, pod.Name)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/sparkapplication/sparkapp_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ func getDriverContainerTerminatedState(podStatus apiv1.PodStatus) *apiv1.Contain
}

func getExecutorContainerTerminatedState(podStatus apiv1.PodStatus) *apiv1.ContainerStateTerminated {
return getContainerTerminatedState(config.SparkExecutorContainerName, podStatus)
state := getContainerTerminatedState(config.Spark3DefaultExecutorContainerName, podStatus)
if state == nil {
state = getContainerTerminatedState(config.SparkExecutorContainerName, podStatus)
}
return state
}

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

0 comments on commit 611c384

Please sign in to comment.