lyy-pineapple commented on code in PR #36952:
URL: https://github.com/apache/spark/pull/36952#discussion_r905767041


##########
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:
   You are right.I has changed it.



##########
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:
   Should a timeout control be added?



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