Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6026#discussion_r30239470
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -91,30 +91,52 @@ private[spark] class Client(
        * available in the alpha API.
        */
       def submitApplication(): ApplicationId = {
    -    // Setup the credentials before doing anything else, so we have don't 
have issues at any point.
    -    setupCredentials()
    -    yarnClient.init(yarnConf)
    -    yarnClient.start()
    -
    -    logInfo("Requesting a new application from cluster with %d 
NodeManagers"
    -      .format(yarnClient.getYarnClusterMetrics.getNumNodeManagers))
    -
    -    // Get a new application from our RM
    -    val newApp = yarnClient.createApplication()
    -    val newAppResponse = newApp.getNewApplicationResponse()
    -    val appId = newAppResponse.getApplicationId()
    -
    -    // Verify whether the cluster has enough resources for our AM
    -    verifyClusterResources(newAppResponse)
    -
    -    // Set up the appropriate contexts to launch our AM
    -    val containerContext = createContainerLaunchContext(newAppResponse)
    -    val appContext = createApplicationSubmissionContext(newApp, 
containerContext)
    -
    -    // Finally, submit and monitor the application
    -    logInfo(s"Submitting application ${appId.getId} to ResourceManager")
    -    yarnClient.submitApplication(appContext)
    -    appId
    +    var appId: ApplicationId = null
    +    try {
    +      // Setup the credentials before doing anything else,
    +      // so we have don't have issues at any point.
    +      setupCredentials()
    +      yarnClient.init(yarnConf)
    +      yarnClient.start()
    +
    +      logInfo("Requesting a new application from cluster with %d 
NodeManagers"
    +        .format(yarnClient.getYarnClusterMetrics.getNumNodeManagers))
    +
    +      // Get a new application from our RM
    +      val newApp = yarnClient.createApplication()
    +      val newAppResponse = newApp.getNewApplicationResponse()
    +      appId = newAppResponse.getApplicationId()
    +
    +      // Verify whether the cluster has enough resources for our AM
    +      verifyClusterResources(newAppResponse)
    +
    +      // Set up the appropriate contexts to launch our AM
    +      val containerContext = createContainerLaunchContext(newAppResponse)
    +      val appContext = createApplicationSubmissionContext(newApp, 
containerContext)
    +
    +      // Finally, submit and monitor the application
    +      logInfo(s"Submitting application ${appId.getId} to ResourceManager")
    +      yarnClient.submitApplication(appContext)
    +      appId
    +    } catch {
    +      case e: Throwable =>
    +        if (appId != null) {
    --- End diff --
    
    I suppose there's no great way to share this with similar code in 
`ApplicationMaster.scala`? maybe not. This could be made into a private method, 
as it is in the other similar code block, but it's not a big deal. LGTM.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to