Skip to content

Commit 5ab2efa

Browse files
zwangshengyanghua
authored andcommitted
[KYUUBI apache#4424][REST] Catch No Node Exception, when list kyuubi engines
### _Why are the changes needed?_ Close apache#4424 Catch No Node Exception, when list kyuubi engines ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [x] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request ![WX20230227-184957](https://user-images.githubusercontent.com/52876270/221544376-2f0d6b4b-0bc4-446e-abb1-d0c79211aea4.png) Closes apache#4425 from zwangsheng/kyuubi-4424. Closes apache#4424 3052b15 [zwangsheng] [Kyuubi apache#4424] Fix scala style 74825cf [zwangsheng] [Kyuubi apache#4424] Throw User Friendly Exception 7e8363c [zwangsheng] [Kyuubi apache#4424] Remove usless file & catch subException 4a3c469 [zwangsheng] [Kyuubi apache#4424] Catch cacth No Node Exception, when list kyuubi engines Authored-by: zwangsheng <[email protected]> Signed-off-by: ulyssesyou <[email protected]>
1 parent 734a667 commit 5ab2efa

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala

+14-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import scala.collection.mutable.ListBuffer
2727
import io.swagger.v3.oas.annotations.media.Content
2828
import io.swagger.v3.oas.annotations.responses.ApiResponse
2929
import io.swagger.v3.oas.annotations.tags.Tag
30+
import org.apache.zookeeper.KeeperException.NoNodeException
3031

3132
import org.apache.kyuubi.{KYUUBI_VERSION, Logging, Utils}
3233
import org.apache.kyuubi.client.api.v1.dto.Engine
@@ -140,9 +141,19 @@ private[v1] class AdminResource extends ApiRequestContext with Logging {
140141
}
141142
case None =>
142143
withDiscoveryClient(fe.getConf) { discoveryClient =>
143-
discoveryClient.getChildren(engineSpace).map { child =>
144-
info(s"Listing engine nodes for $engineSpace/$child")
145-
engineNodes ++= discoveryClient.getServiceNodesInfo(s"$engineSpace/$child")
144+
try {
145+
discoveryClient.getChildren(engineSpace).map { child =>
146+
info(s"Listing engine nodes for $engineSpace/$child")
147+
engineNodes ++= discoveryClient.getServiceNodesInfo(s"$engineSpace/$child")
148+
}
149+
} catch {
150+
case nne: NoNodeException =>
151+
error(
152+
s"No such engine for user: $userName, " +
153+
s"engine type: $engineType, share level: $shareLevel, subdomain: $subdomain",
154+
nne)
155+
throw new NotFoundException(s"No such engine for user: $userName, " +
156+
s"engine type: $engineType, share level: $shareLevel, subdomain: $subdomain")
146157
}
147158
}
148159
}

0 commit comments

Comments
 (0)