Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,14 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
throw new ForbiddenException(
s"$userName is not allowed to close the session $sessionHandleStr")
}
fe.be.closeSession(SessionHandle.fromUUID(sessionHandleStr))
Response.ok(s"Session $sessionHandleStr is closed successfully.").build()
val sessionHandle = SessionHandle.fromUUID(sessionHandleStr)
fe.be.sessionManager.getSessionOption(sessionHandle) match {
case Some(_) =>
fe.be.closeSession(sessionHandle)
Response.ok(s"Session $sessionHandleStr is closed successfully.").build()
case None =>
throw new NotFoundException(s"Invalid session handle: $sessionHandleStr")
}
}

@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,14 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
@Path("{sessionHandle}")
def closeSession(@PathParam("sessionHandle") sessionHandleStr: String): Response = {
info(s"Received request of closing $sessionHandleStr")
fe.be.closeSession(sessionHandleStr)
Response.ok().build()
val sessionHandle = SessionHandle.fromUUID(sessionHandleStr)
fe.be.sessionManager.getSessionOption(sessionHandle) match {
case Some(_) =>
fe.be.closeSession(sessionHandle)
Response.ok().build()
case None =>
throw new NotFoundException(s"Invalid session handle: $sessionHandleStr")
}
}

@ApiResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ class AdminResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(sessions2.isEmpty)
}

test("delete non-existent admin session returns 404") {
val nonExistentSessionId = java.util.UUID.randomUUID().toString
val response = webTarget.path(s"api/v1/admin/sessions/$nonExistentSessionId").request()
.header(AUTHORIZATION_HEADER, HttpAuthUtils.basicAuthorizationHeader(Utils.currentUser))
.delete()
assert(response.getStatus === 404)
assert(response.readEntity(classOf[String]).contains("Invalid"))
}

test("list sessions/operations with filter") {
fe.be.openSession(
HIVE_CLI_SERVICE_PROTOCOL_V2,
Expand Down
Loading