-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-34018][K8S] NPE in ExecutorPodsSnapshot #31071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ private[spark] case class ExecutorPodsSnapshot(executorPods: Map[Long, ExecutorP | |
|
|
||
| object ExecutorPodsSnapshot extends Logging { | ||
| private var shouldCheckAllContainers: Boolean = _ | ||
| private var sparkContainerName: String = _ | ||
| private var sparkContainerName: String = DEFAULT_EXECUTOR_CONTAINER_NAME | ||
|
|
||
| def apply(executorPods: Seq[Pod]): ExecutorPodsSnapshot = { | ||
| ExecutorPodsSnapshot(toStatesByExecutorId(executorPods)) | ||
|
|
@@ -80,24 +80,21 @@ object ExecutorPodsSnapshot extends Logging { | |
| .anyMatch(t => t != null && t.getExitCode != 0)) { | ||
| PodFailed(pod) | ||
| } else { | ||
| // Otherwise look for the Spark container | ||
| val sparkContainerStatusOpt = pod.getStatus.getContainerStatuses.asScala | ||
| .find(_.getName() == sparkContainerName) | ||
| sparkContainerStatusOpt match { | ||
| case Some(sparkContainerStatus) => | ||
| sparkContainerStatus.getState.getTerminated match { | ||
| case t if t.getExitCode != 0 => | ||
| PodFailed(pod) | ||
| case t if t.getExitCode == 0 => | ||
| // Otherwise look for the Spark container and get the exit code if present. | ||
| val sparkContainerExitCode = pod.getStatus.getContainerStatuses.asScala | ||
| .find(_.getName() == sparkContainerName).flatMap(x => Option(x.getState)) | ||
| .flatMap(x => Option(x.getTerminated)).flatMap(x => Option(x.getExitCode)) | ||
| .map(_.toInt) | ||
| sparkContainerExitCode match { | ||
| case Some(t) => | ||
| t match { | ||
| case 0 => | ||
| PodSucceeded(pod) | ||
| case _ => | ||
| PodRunning(pod) | ||
| PodFailed(pod) | ||
| } | ||
|
||
| // If we can't find the Spark container status, fall back to the pod status. This is | ||
| // expected to occur during pod startup and other situations. | ||
| // No exit code means we are running. | ||
| case _ => | ||
| logDebug(s"Unable to find container ${sparkContainerName} in pod ${pod} " + | ||
| "defaulting to entire pod status (running).") | ||
| PodRunning(pod) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have three case statements before this line,
t is nullandt is not null and exit code is non-zeroandt is not null and exist code iszero` is covered. When we fall into here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't but this is to prevent the spurious "non-exhaustive match" warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, got it.