jkleckner commented on a change in pull request #30283:
URL: https://github.com/apache/spark/pull/30283#discussion_r527326505
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientApplication.scala
##########
@@ -133,29 +136,37 @@ private[spark] class Client(
.endVolume()
.endSpec()
.build()
- Utils.tryWithResource(
- kubernetesClient
- .pods()
- .withName(resolvedDriverPod.getMetadata.getName)
- .watch(watcher)) { _ =>
- val createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod)
- try {
- val otherKubernetesResources =
- resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap)
- addDriverOwnerReference(createdDriverPod, otherKubernetesResources)
- kubernetesClient.resourceList(otherKubernetesResources:
_*).createOrReplace()
- } catch {
- case NonFatal(e) =>
- kubernetesClient.pods().delete(createdDriverPod)
- throw e
- }
- if (waitForAppCompletion) {
- logInfo(s"Waiting for application $appName to finish...")
- watcher.awaitCompletion()
- logInfo(s"Application $appName finished.")
- } else {
- logInfo(s"Deployed Spark application $appName into Kubernetes.")
+ val driverPodName = resolvedDriverPod.getMetadata.getName
+ var watch: Watch = null
+ val createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod)
+ try {
+ val otherKubernetesResources =
resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap)
+ addDriverOwnerReference(createdDriverPod, otherKubernetesResources)
+ kubernetesClient.resourceList(otherKubernetesResources:
_*).createOrReplace()
+ } catch {
+ case NonFatal(e) =>
+ kubernetesClient.pods().delete(createdDriverPod)
+ throw e
+ }
+ val sId = Seq(kubernetesConf.namespace(), driverPodName).mkString(":")
+ breakable {
+ while (true) {
+ val podWithName = kubernetesClient
+ .pods()
+ .withName(driverPodName)
+
+ watcher.reset()
+
+ watch = podWithName.watch(watcher)
+
Review comment:
Done
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientApplication.scala
##########
@@ -133,29 +136,37 @@ private[spark] class Client(
.endVolume()
.endSpec()
.build()
- Utils.tryWithResource(
- kubernetesClient
- .pods()
- .withName(resolvedDriverPod.getMetadata.getName)
- .watch(watcher)) { _ =>
- val createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod)
- try {
- val otherKubernetesResources =
- resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap)
- addDriverOwnerReference(createdDriverPod, otherKubernetesResources)
- kubernetesClient.resourceList(otherKubernetesResources:
_*).createOrReplace()
- } catch {
- case NonFatal(e) =>
- kubernetesClient.pods().delete(createdDriverPod)
- throw e
- }
- if (waitForAppCompletion) {
- logInfo(s"Waiting for application $appName to finish...")
- watcher.awaitCompletion()
- logInfo(s"Application $appName finished.")
- } else {
- logInfo(s"Deployed Spark application $appName into Kubernetes.")
+ val driverPodName = resolvedDriverPod.getMetadata.getName
+ var watch: Watch = null
+ val createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod)
+ try {
+ val otherKubernetesResources =
resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap)
+ addDriverOwnerReference(createdDriverPod, otherKubernetesResources)
+ kubernetesClient.resourceList(otherKubernetesResources:
_*).createOrReplace()
+ } catch {
+ case NonFatal(e) =>
+ kubernetesClient.pods().delete(createdDriverPod)
+ throw e
+ }
+ val sId = Seq(kubernetesConf.namespace(), driverPodName).mkString(":")
+ breakable {
+ while (true) {
+ val podWithName = kubernetesClient
+ .pods()
+ .withName(driverPodName)
+
+ watcher.reset()
+
+ watch = podWithName.watch(watcher)
+
+ watcher.eventReceived(Action.MODIFIED, podWithName.get())
+
Review comment:
Done
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientApplication.scala
##########
@@ -133,29 +136,37 @@ private[spark] class Client(
.endVolume()
.endSpec()
.build()
- Utils.tryWithResource(
- kubernetesClient
- .pods()
- .withName(resolvedDriverPod.getMetadata.getName)
- .watch(watcher)) { _ =>
- val createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod)
- try {
- val otherKubernetesResources =
- resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap)
- addDriverOwnerReference(createdDriverPod, otherKubernetesResources)
- kubernetesClient.resourceList(otherKubernetesResources:
_*).createOrReplace()
- } catch {
- case NonFatal(e) =>
- kubernetesClient.pods().delete(createdDriverPod)
- throw e
- }
- if (waitForAppCompletion) {
- logInfo(s"Waiting for application $appName to finish...")
- watcher.awaitCompletion()
- logInfo(s"Application $appName finished.")
- } else {
- logInfo(s"Deployed Spark application $appName into Kubernetes.")
+ val driverPodName = resolvedDriverPod.getMetadata.getName
+ var watch: Watch = null
+ val createdDriverPod = kubernetesClient.pods().create(resolvedDriverPod)
+ try {
+ val otherKubernetesResources =
resolvedDriverSpec.driverKubernetesResources ++ Seq(configMap)
+ addDriverOwnerReference(createdDriverPod, otherKubernetesResources)
+ kubernetesClient.resourceList(otherKubernetesResources:
_*).createOrReplace()
+ } catch {
+ case NonFatal(e) =>
+ kubernetesClient.pods().delete(createdDriverPod)
+ throw e
+ }
+ val sId = Seq(kubernetesConf.namespace(), driverPodName).mkString(":")
+ breakable {
+ while (true) {
+ val podWithName = kubernetesClient
+ .pods()
+ .withName(driverPodName)
+
+ watcher.reset()
+
+ watch = podWithName.watch(watcher)
+
+ watcher.eventReceived(Action.MODIFIED, podWithName.get())
+
+ if(watcher.watchOrStop(sId)) {
+ logInfo(s"Stop watching as the pod has completed.")
Review comment:
Done
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/LoggingPodStatusWatcher.scala
##########
@@ -28,8 +29,10 @@ import org.apache.spark.SparkException
import org.apache.spark.internal.Logging
import org.apache.spark.util.ThreadUtils
+
Review comment:
Done
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/LoggingPodStatusWatcher.scala
##########
@@ -77,9 +87,18 @@ private[k8s] class LoggingPodStatusWatcherImpl(
}
}
+ override def reset(): Unit = {
Review comment:
Done
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]