tgravescs commented on code in PR #36952:
URL: https://github.com/apache/spark/pull/36952#discussion_r903866092


##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnRMClient.scala:
##########
@@ -93,10 +93,16 @@ private[spark] class YarnRMClient extends Logging {
    * @param status The final status of the AM.
    * @param diagnostics Diagnostics message to include in the final status.
    */
-  def unregister(status: FinalApplicationStatus, diagnostics: String = ""): 
Unit = synchronized {
-    if (registered) {
-      amClient.unregisterApplicationMaster(status, diagnostics, 
uiHistoryAddress)
+  def unregister(status: FinalApplicationStatus,
+                 conf: YarnConfiguration,

Review Comment:
   indentation should be 4 spaces



##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnRMClient.scala:
##########
@@ -93,10 +93,16 @@ private[spark] class YarnRMClient extends Logging {
    * @param status The final status of the AM.
    * @param diagnostics Diagnostics message to include in the final status.
    */
-  def unregister(status: FinalApplicationStatus, diagnostics: String = ""): 
Unit = synchronized {
-    if (registered) {
-      amClient.unregisterApplicationMaster(status, diagnostics, 
uiHistoryAddress)
+  def unregister(status: FinalApplicationStatus,
+                 conf: YarnConfiguration,
+                 diagnostics: String = ""): Unit = synchronized {
+    if (!registered) {
+      amClient = AMRMClient.createAMRMClient()

Review Comment:
   this is very odd to register during unregister, what if it was the register 
or start that failed? 
   if it timed out and you have a very high timeout I assume you would wait 
that again.
   I'm definitely a bit hesitant about this change.



##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala:
##########
@@ -374,29 +374,33 @@ private[spark] class ApplicationMaster(
    */
   final def unregister(status: FinalApplicationStatus, diagnostics: String = 
null): Unit = {
     synchronized {
-      if (registered && !unregistered) {
+      if (!unregistered) {
         logInfo(s"Unregistering ApplicationMaster with $status" +
           Option(diagnostics).map(msg => s" (diag message: 
$msg)").getOrElse(""))
         unregistered = true
-        client.unregister(status, Option(diagnostics).getOrElse(""))
+        client.unregister(status, yarnConf, Option(diagnostics).getOrElse(""))
       }
     }
   }
 
   final def finish(status: FinalApplicationStatus, code: Int, msg: String = 
null): Unit = {
     synchronized {
       if (!finished) {
+        var errorMsg = msg
         val inShutdown = ShutdownHookManager.inShutdown()
         if (registered || !isClusterMode) {
           exitCode = code
           finalStatus = status
         } else {
           finalStatus = FinalApplicationStatus.FAILED
           exitCode = ApplicationMaster.EXIT_SC_NOT_INITED
+          if(msg == null) {

Review Comment:
   should have space after if



##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala:
##########
@@ -374,29 +374,33 @@ private[spark] class ApplicationMaster(
    */
   final def unregister(status: FinalApplicationStatus, diagnostics: String = 
null): Unit = {
     synchronized {
-      if (registered && !unregistered) {
+      if (!unregistered) {
         logInfo(s"Unregistering ApplicationMaster with $status" +
           Option(diagnostics).map(msg => s" (diag message: 
$msg)").getOrElse(""))
         unregistered = true
-        client.unregister(status, Option(diagnostics).getOrElse(""))
+        client.unregister(status, yarnConf, Option(diagnostics).getOrElse(""))
       }
     }
   }
 
   final def finish(status: FinalApplicationStatus, code: Int, msg: String = 
null): Unit = {
     synchronized {
       if (!finished) {
+        var errorMsg = msg
         val inShutdown = ShutdownHookManager.inShutdown()
         if (registered || !isClusterMode) {
           exitCode = code
           finalStatus = status
         } else {
           finalStatus = FinalApplicationStatus.FAILED
           exitCode = ApplicationMaster.EXIT_SC_NOT_INITED
+          if(msg == null) {
+            errorMsg = "User did not initialize spark context!"

Review Comment:
   how do you know user didn't initialize spark context vs something bad 
happening and it failing to initialize?  this could be more confusing.  maybe 
"Failed to initialize Spark context"



-- 
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]

Reply via email to