You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2023/06/20 06:12:37 UTC

[GitHub] [kyuubi] pan3793 commented on a diff in pull request #2819: [KYUUBI #2820][SUB-TASK][KPIP-4] Support to redirect getLocalLog and closeBatchSession requests across kyuubi instances

pan3793 commented on code in PR #2819:
URL: https://github.com/apache/kyuubi/pull/2819#discussion_r1234781424


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala:
##########
@@ -204,14 +229,45 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
         throw new NotAllowedException(t.getMessage)
     }
 
-    if (!session.user.equals(userName)) {
-      throw new NotAllowedException(
-        s"$userName is not allowed to close the session belong to ${session.user}")
+    Option(sessionManager.getBatchSessionImpl(sessionHandle)).map { batchSession =>
+      if (userName != batchSession.user) {
+        throw new NotAllowedException(
+          s"$userName is not allowed to close the session belong to ${batchSession.user}")
+      }
+      sessionManager.closeSession(batchSession.handle)
+      val (success, msg) = batchSession.batchJobSubmissionOp.getKillMessage
+      new CloseBatchResponse(success, msg)
+    }.getOrElse {
+      Option(sessionManager.getBatchSessionMetadata(batchId)).map { metadata =>
+        if (userName != metadata.username) {
+          throw new NotAllowedException(
+            s"$userName is not allowed to close the session belong to ${metadata.username}")
+        } else if (OperationState.isTerminal(OperationState.withName(metadata.state)) ||

Review Comment:
   should `||` be replaced with `&&`? @turboFei 



-- 
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: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org