This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new a51b45000 [KYUUBI #4811] Do not update app info after batch or 
application terminated
a51b45000 is described below

commit a51b45000db4c2864715d174837c70cba0743fc4
Author: fwang12 <[email protected]>
AuthorDate: Wed May 10 20:34:08 2023 +0800

    [KYUUBI #4811] Do not update app info after batch or application terminated
    
    ### _Why are the changes needed?_
    
    If the application has been terminated, it is not needed to update 
application. and It can prevent that, the correct application info is 
overwritten by NOT_FOUND state.
    
    If the batch has been terminated, we shall get the batch report from 
metastore.
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run 
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4811 from turboFei/k8s_status.
    
    Closes #4811
    
    8fc6fd6ab [fwang12] check app id defined
    87b0797e0 [fwang12] if batch state is terminal, get state from metadata 
store
    488433e05 [fwang12] save
    
    Authored-by: fwang12 <[email protected]>
    Signed-off-by: fwang12 <[email protected]>
    (cherry picked from commit 299df0d7c2ad9ad6509861fada2d25ee2933e1fd)
    Signed-off-by: fwang12 <[email protected]>
---
 .../org/apache/kyuubi/operation/BatchJobSubmission.scala    | 13 ++++++++-----
 .../org/apache/kyuubi/server/api/v1/BatchesResource.scala   |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
index 702a9a917..000f20d13 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
@@ -308,11 +308,14 @@ class BatchJobSubmission(
   }
 
   private def updateApplicationInfoMetadataIfNeeded(): Unit = {
-    val newApplicationStatus = currentApplicationInfo()
-    if (newApplicationStatus.map(_.state) != _applicationInfo.map(_.state)) {
-      _applicationInfo = newApplicationStatus
-      updateBatchMetadata()
-      info(s"Batch report for $batchId, ${_applicationInfo}")
+    if (applicationId(_applicationInfo).isEmpty ||
+      !_applicationInfo.map(_.state).exists(ApplicationState.isTerminated)) {
+      val newApplicationStatus = currentApplicationInfo()
+      if (newApplicationStatus.map(_.state) != _applicationInfo.map(_.state)) {
+        _applicationInfo = newApplicationStatus
+        updateBatchMetadata()
+        info(s"Batch report for $batchId, ${_applicationInfo}")
+      }
     }
   }
 
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
index 38ce0e297..11c36c757 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
@@ -82,7 +82,7 @@ private[v1] class BatchesResource extends ApiRequestContext 
with Logging {
     var appState: String = null
     var appDiagnostic: String = null
 
-    if (batchAppStatus.nonEmpty) {
+    if (!OperationState.isTerminal(batchOpStatus.state) && 
batchAppStatus.nonEmpty) {
       appId = batchAppStatus.get.id
       appUrl = batchAppStatus.get.url.orNull
       appState = batchAppStatus.get.state.toString

Reply via email to