[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 <fwang12@ebay.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
fwang12 2023-10-09 14:35:47 +08:00
parent 6444c82d2e
commit 7eac400488

View File

@ -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