From 7eac40048807655306fface8dfef9c8795ea595d Mon Sep 17 00:00:00 2001 From: fwang12 Date: Mon, 9 Oct 2023 14:35:47 +0800 Subject: [PATCH] [KYUUBI #4994][FOLLOWUP] Respect the engine type and share level for listing all engines ### _Why are the changes needed?_ Now, the specified engine type and share level does not work ### _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/contributing/code/testing.html#running-tests) locally before make a pull request ### _Was this patch authored or co-authored using generative AI tooling?_ No Closes #5353 from turboFei/list_all_engines. Closes #4994 49ad1acdb [fwang12] refactor 295665bb1 [fwang12] respect the engine share level and type Authored-by: fwang12 Signed-off-by: fwang12 --- .../kyuubi/server/api/v1/AdminResource.scala | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala index 5f410ab7d..3c6f2a197 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/AdminResource.scala @@ -298,15 +298,15 @@ private[v1] class AdminResource extends ApiRequestContext with Logging { } val engines = ListBuffer[Engine]() val engineSpace = fe.getConf.get(HA_NAMESPACE) - val shareLevel = fe.getConf.get(ENGINE_SHARE_LEVEL) - val engineType = fe.getConf.get(ENGINE_TYPE) + val finalShareLevel = Option(shareLevel).getOrElse(fe.getConf.get(ENGINE_SHARE_LEVEL)) + val finalEngineType = Option(engineType).getOrElse(fe.getConf.get(ENGINE_TYPE)) withDiscoveryClient(fe.getConf) { discoveryClient => - val commonParent = s"/${engineSpace}_${KYUUBI_VERSION}_${shareLevel}_$engineType" + val commonParent = s"/${engineSpace}_${KYUUBI_VERSION}_${finalShareLevel}_$finalEngineType" info(s"Listing engine nodes for $commonParent") try { discoveryClient.getChildren(commonParent).map { user => - val engine = getEngine(user, engineType, shareLevel, "", "") + val engine = getEngine(user, finalEngineType, finalShareLevel, "", "") val engineSpace = getEngineSpace(engine) discoveryClient.getChildren(engineSpace).map { child => info(s"Listing engine nodes for $engineSpace/$child") @@ -324,9 +324,12 @@ private[v1] class AdminResource extends ApiRequestContext with Logging { } } catch { case nne: NoNodeException => - error(s"No such engine for engine type: $engineType, share level: $shareLevel", nne) + error( + s"No such engine for engine type: $finalEngineType," + + s" share level: $finalShareLevel", + nne) throw new NotFoundException( - s"No such engine for engine type: $engineType, share level: $shareLevel") + s"No such engine for engine type: $finalEngineType, share level: $finalShareLevel") } } return engines.toSeq