wangzhigang1999 opened a new pull request, #7489:
URL: https://github.com/apache/kyuubi/pull/7489
### Why are the changes needed?
Closes #7488.
When a **RUNNING** batch is canceled via `DELETE /api/v1/batches/{batchId}`,
the operation state correctly transitions to `CANCELED` and the Spark
application is actually killed, but the batch keeps reporting `appState =
RUNNING` permanently. The REST API returns the contradictory pair
`state=CANCELED, appState=RUNNING`, which is misleading to clients and the Web
UI (a canceled batch looks like its application is still alive).
Root cause: in `BatchJobSubmission.close()` the kill-success branch sets the
operation state to `CANCELED` and persists metadata via `updateBatchMetadata()`
without re-polling the application info. `updateBatchMetadata()` writes
`engineState = getAppState(state, appInfo.state)`, and `getAppState(...)` only
coerces a non-terminated application state to `UNKNOWN` when `opState ==
ERROR`; it leaves `CANCELED` untouched and returns the last-polled `RUNNING`
as-is. Because status polling stops once the operation is closed, the stale
`RUNNING` is persisted and reported forever. The peer-instance-closed
cancellation path is affected the same way. Affects master and 1.10.1.
This change reconciles a non-terminal application state to `KILLED` when the
operation state is `CANCELED` (the application has been killed), mirroring the
existing `ERROR -> UNKNOWN` handling in `getAppState`.
### How was this patch tested?
Added a regression assertion to the existing `BatchesResourceSuite` "expose
the metrics with operation type and current state" test, which runs for both
batch v1 and v2. That test submits a long-running `DriverSubmissionTest` batch,
waits until it reaches `RUNNING`, then cancels it via `DELETE`, and now also
asserts the reported `appState` is `KILLED`. By construction the assertion
fails on the previous behavior (`appState` would be the stale `RUNNING`) and
passes with this change. The full suite launches a real Spark batch, so it runs
in CI; I did not run it locally.
The bug itself was reproduced on a live Kubernetes Kyuubi 1.10.1 deployment,
as detailed in #7488: a canceled RUNNING batch kept `appState=RUNNING` while
its driver Pod and Service were already deleted (the `engine-ui` reverse proxy
to its `appUrl` returned HTTP 502).
### Was this patch authored or co-authored using generative AI tooling?
Yes. Claude (Opus 4.8) assisted with the live reproduction, root-cause
analysis, implementation, and drafting of this PR. The author reviewed every
line.
Assisted-by: Claude:claude-opus-4-8
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]