pan3793 commented on code in PR #2819:
URL: https://github.com/apache/kyuubi/pull/2819#discussion_r1234828341
##########
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:
After second thought, `metadata.kyuubiInstance == fe.connectionUrl` should
not always be `false` but this is actually guard to avoid cyclic redirection,
opened https://github.com/apache/kyuubi/pull/4981 to refactor it.
##########
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:
After second thought, `metadata.kyuubiInstance == fe.connectionUrl` should
always be `false` but this is actually guard to avoid cyclic redirection,
opened https://github.com/apache/kyuubi/pull/4981 to refactor it.
--
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]