-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-47573][K8S] Support custom driver log url #45728
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
base: master
Are you sure you want to change the base?
Conversation
e12ba58
to
a3fe442
Compare
412e9d0
to
409ce35
Compare
@dongjoon-hyun What do you think? |
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. |
409ce35
to
b0e1cde
Compare
@dongjoon-hyun thanks for the pointer! Is the live log supported by the Spark History Server? Or are they only available during runtime of the Spark app? Are they log collected? Executor logs are links to the log collections service but driver logs are not? Sounds different to the |
It's not the same of course, @EnricoMi .
What I wrote is |
Haven't seen the live log feature before. |
Ya, maybe I made you confused.
The
So, it is not relevant to this PR technically. |
Thanks for clarification. |
Let me reopen this for now because it seems to be closed by the bot. |
@dongjoon-hyun any thoughts on this? |
@dongjoon-hyun can we get this into the Spark 4.0.0 release? |
Let me check this PR quickly since I'm currently preparing Apache Spark 4.0.0-preview2, @EnricoMi . |
@@ -220,8 +220,20 @@ private[spark] object UI { | |||
.stringConf | |||
.createOptional | |||
|
|||
val CUSTOM_DRIVER_LOG_URL = ConfigBuilder("spark.ui.custom.driver.log.url") |
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.
Since this doesn't have spark.kubernetes.
prefix, this is supposed to work with YARN, @EnricoMi . Are you sure?
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.
This was just derived from spark.ui.custom.executor.log.url
, where I suspect this should be similar. The property name does not mention Yarn, and documentation says that only K8s support this.
@@ -63,6 +63,9 @@ object Constants { | |||
val UI_PORT_NAME = "spark-ui" | |||
|
|||
// Environment Variables | |||
val ENV_DRIVER_ATTRIBUTE_APP_ID = "SPARK_DRIVER_ATTRIBUTE_APP_ID" | |||
val ENV_DRIVER_ATTRIBUTE_KUBERNETES_NAMESPACE = "SPARK_DRIVER_ATTRIBUTE_KUBERNETES_NAMESPACE" |
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.
Just a question: we need this K8s namespace attribute additionally only for driver logs?
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.
yes
val driverCustomEnvs = KubernetesUtils.buildEnvVars( | ||
Seq(ENV_APPLICATION_ID -> conf.appId) ++ conf.environment) | ||
Seq(ENV_APPLICATION_ID -> conf.appId) ++ conf.environment ++ driverAttributes) |
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.
Is this inevitable to inject both ENV_APPLICATION_ID
and ENV_DRIVER_ATTRIBUTE_APP_ID
? This looks like a redundancy for me.
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.
This is the same pattern as in
Lines 146 to 173 in 584b6db
val attributes = if (kubernetesConf.get(UI.CUSTOM_EXECUTOR_LOG_URL).isDefined) { | |
Map( | |
ENV_EXECUTOR_ATTRIBUTE_APP_ID -> kubernetesConf.appId, | |
ENV_EXECUTOR_ATTRIBUTE_EXECUTOR_ID -> kubernetesConf.executorId) | |
} else { | |
Map.empty[String, String] | |
} | |
KubernetesUtils.buildEnvVars( | |
Seq( | |
ENV_DRIVER_URL -> driverUrl, | |
ENV_EXECUTOR_CORES -> execResources.cores.get.toString, | |
ENV_EXECUTOR_MEMORY -> executorMemoryString, | |
ENV_APPLICATION_ID -> kubernetesConf.appId, | |
// This is to set the SPARK_CONF_DIR to be /opt/spark/conf | |
ENV_SPARK_CONF_DIR -> SPARK_CONF_DIR_INTERNAL, | |
ENV_EXECUTOR_ID -> kubernetesConf.executorId, | |
ENV_RESOURCE_PROFILE_ID -> resourceProfile.id.toString) | |
++ attributes | |
++ kubernetesConf.environment | |
++ sparkAuthSecret | |
++ Seq(ENV_CLASSPATH -> kubernetesConf.get(EXECUTOR_CLASS_PATH).orNull) | |
++ allOpts) ++ | |
KubernetesUtils.buildEnvVarsWithFieldRef( | |
Seq( | |
(ENV_EXECUTOR_POD_IP, "v1", "status.podIP"), | |
(ENV_EXECUTOR_POD_NAME, "v1", "metadata.name") | |
)) |
@@ -144,6 +144,11 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp | |||
ThreadUtils.newDaemonSingleThreadScheduledExecutor("cleanup-decommission-execs") | |||
} | |||
|
|||
override def getDriverLogUrls: Option[Map[String, String]] = { |
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.
Instead of here, please override this at KubernetesClusterSchedulerBackend
instead of CoarseGrainedSchedulerBackend
because this PR aims for K8s only.
For now, only K8s cluster manager supports this configuration.
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.
moved
4609e87
to
a09526c
Compare
a09526c
to
188c968
Compare
Could you fix the compilation errors? |
188c968
to
e0872a4
Compare
@dongjoon-hyun fixed |
e0872a4
to
9215c17
Compare
"This configuration replaces original log urls in event log, which will be also effective " + | ||
"when accessing the application on history server. The new log urls must be permanent, " + | ||
"otherwise you might have dead link for executor log urls.") | ||
.version("4.0.0") |
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.
Shall we use 4.1.0
since master
branch is 4.1.0-SNAPSHOT
?
Line 29 in a30bdc3
<version>4.1.0-SNAPSHOT</version> |
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.
done
docs/configuration.md
Outdated
<p/> | ||
For now, only K8s cluster manager supports this configuration. | ||
</td> | ||
<td>4.0.0</td> |
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.
ditto. Let's use 4.1.0
since master
branch is 4.1.0-SNAPSHOT
.
Line 29 in a30bdc3
<version>4.1.0-SNAPSHOT</version> |
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.
updated
…iver Pod" This reverts commit 69820e0.
…rnetesClusterSchedulerBackend
9215c17
to
aebcc62
Compare
What changes were proposed in this pull request?
Add config
spark.ui.custom.driver.log.url
to Kubernetes resource manager allow setting log url templates similar tospark.ui.custom.executor.log.url
.Allows for
Supports these variables:
Adds driver pod environment variable
SPARK_DRIVER_POD_NAME
.Why are the changes needed?
Running Spark on Kubernetes requires persisting the logs elsewhere. Having the Spark UI link to those logs is very useful. This should be possible for driver logs similar to executor logs.
Does this PR introduce any user-facing change?
Spark UI provides links to logs when run on Kubernetes.
How was this patch tested?
Unit test and manually tested on minikube K8S cluster.
Was this patch authored or co-authored using generative AI tooling?
No