HwangDongJun commented on code in PR #58187:
URL: https://github.com/apache/spark/pull/58187#discussion_r4163584199
##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientApplication.scala:
##########
@@ -136,43 +188,75 @@ private[spark] class Client(
val driverPodName = resolvedDriverPod.getMetadata.getName
// setup resources before pod creation
- val preKubernetesResources =
resolvedDriverSpec.driverPreKubernetesResources
- try {
- kubernetesClient.resourceList(preKubernetesResources:
_*).forceConflicts().serverSideApply()
- } catch {
- case NonFatal(e) =>
- logError("Please check \"kubectl auth can-i create [resource]\"
first." +
- " It should be yes. And please also check your feature step
implementation.")
- kubernetesClient.resourceList(preKubernetesResources: _*).delete()
- throw e
- }
+ // SPARK-38079: the driver's own base config map (mounted as
SPARK_CONF_VOLUME_DRIVER
+ // above) must also be created before the pod itself, to avoid a
"configmap ... not
+ // found" mount race between the driver pod and the config map it depends
on.
+ val preKubernetesResources =
resolvedDriverSpec.driverPreKubernetesResources ++ Seq(configMap)
Review Comment:
Yes — implemented exactly as proposed. The driver pod is now created first
with `spec.schedulingGates` (`PRE_RESOURCES_SCHEDULING_GATE`), every
pre-resource is created in a single call that already carries the owner
reference, and the gate is removed only once that succeeds (details in [the
reply
above](https://github.com/apache/spark/pull/58187#discussion_r4129910475)).
This removes the ownerless window, the shutdown hook, the second apply, and the
`OwnerReferencesPermissionEnforcement` issue, as you described.
On the `nodeName` fallback: a pod template with a fixed `spec.nodeName` is
now translated to an equivalent `nodeSelector` (`kubernetes.io/hostname:
<name>`) before the gate is added, since a pod can't be created with both
`nodeName` and a non-empty `schedulingGates` set. If the user has already set
an explicit `spark.kubernetes.driver.node.selector.kubernetes.io/hostname`,
that's left untouched rather than silently overwritten.
One trade-off worth calling out: this fallback doesn't preserve
node-affinity semantics that differ from a plain `nodeSelector` — in
particular, `nodeName` bypasses taints (and a toleration workaround some users
may rely on for that), while `nodeSelector` doesn't. I'll note this as a known
limitation in the PR description.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]