Skip to content

Commit b115c8d

Browse files
committed
[KYUUBI #2978] [SUB-TASK][KPIP-4] If batch app status not found from cluster manager, fall back to metadata store
### _Why are the changes needed?_ Because the kyuubi batch is not closed once the session completed(reserve the batch log for sometime). If a batch has been finished for some time, it might can not be found from RM, which has max reserved application list limitation, for this case, we need fall back to metadata for batch info response. Before: <img width="1085" alt="image" src="https://user-images.githubusercontent.com/6757692/176682626-294da2bd-eb37-4b6f-95e9-052990fa2a85.png"> ### _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 - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #2978 from turboFei/fall_back_metadata. Closes #2978 a0a51ac [Fei Wang] If batch app status not found, fall back to metadata Authored-by: Fei Wang <fwang12@ebay.com> Signed-off-by: Fei Wang <fwang12@ebay.com>
1 parent bd2f5b2 commit b115c8d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,23 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
7171
val batchAppStatus = batchOp.currentApplicationState.getOrElse(Map.empty)
7272

7373
val name = Option(batchOp.batchName).getOrElse(batchAppStatus.get(APP_NAME_KEY).orNull)
74-
val appId = batchAppStatus.get(APP_ID_KEY).orNull
75-
val appUrl = batchAppStatus.get(APP_URL_KEY).orNull
76-
val appState = batchAppStatus.get(APP_STATE_KEY).orNull
77-
val appDiagnostic = batchAppStatus.get(APP_ERROR_KEY).orNull
74+
var appId: String = null
75+
var appUrl: String = null
76+
var appState: String = null
77+
var appDiagnostic: String = null
78+
79+
if (batchAppStatus.nonEmpty) {
80+
appId = batchAppStatus.get(APP_ID_KEY).orNull
81+
appUrl = batchAppStatus.get(APP_URL_KEY).orNull
82+
appState = batchAppStatus.get(APP_STATE_KEY).orNull
83+
appDiagnostic = batchAppStatus.get(APP_ERROR_KEY).orNull
84+
} else {
85+
val metadata = sessionManager.getBatchMetadata(batchOp.batchId)
86+
appId = metadata.engineId
87+
appUrl = metadata.engineUrl
88+
appState = metadata.engineState
89+
appDiagnostic = metadata.engineError.orNull
90+
}
7891

7992
new Batch(
8093
batchOp.batchId,

0 commit comments

Comments
 (0)