Github user vanzin commented on a diff in the pull request: https://github.com/apache/spark/pull/11746#discussion_r73768836 --- Diff: core/src/main/scala/org/apache/spark/deploy/worker/DriverRunner.scala --- @@ -78,49 +80,53 @@ private[deploy] class DriverRunner( private[worker] def start() = { new Thread("DriverRunner for " + driverId) { override def run() { + var shutdownHook: AnyRef = null try { - val driverDir = createWorkingDirectory() - val localJarFilename = downloadUserJar(driverDir) - - def substituteVariables(argument: String): String = argument match { - case "{{WORKER_URL}}" => workerUrl - case "{{USER_JAR}}" => localJarFilename - case other => other + shutdownHook = ShutdownHookManager.addShutdownHook { () => + logInfo(s"Worker shutting down, killing driver $driverId") + kill() } - // TODO: If we add ability to submit multiple jars they should also be added here - val builder = CommandUtils.buildProcessBuilder(driverDesc.command, securityManager, - driverDesc.mem, sparkHome.getAbsolutePath, substituteVariables) - launchDriver(builder, driverDir, driverDesc.supervise) - } - catch { - case e: Exception => finalException = Some(e) - } + // prepare driver jars and launch driver + val exitCode = prepareAndLaunchDriver() - val state = - if (killed) { - DriverState.KILLED - } else if (finalException.isDefined) { - DriverState.ERROR + // set final state depending on if forcibly killed and process exit code + finalState = if (exitCode == 0) { + Some(DriverState.FINISHED) + } else if (killed) { + Some(DriverState.KILLED) } else { - finalExitCode match { - case Some(0) => DriverState.FINISHED - case _ => DriverState.FAILED - } + Some(DriverState.FAILED) } + } + catch { + case e: Exception => + kill() + finalState = Some(DriverState.ERROR) + finalException = Some(e) + } + finally { --- End diff -- nit: move to previous line
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org