dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

[Fix-18311][TaskPlugin] Fix task process kill status check

Open zhuxiangyi opened this issue 6 months ago • 5 comments

Was this PR generated or assisted by AI?

YES. Codex/ChatGPT assisted with debugging, code changes, tests, issue drafting, and PR draft preparation. I reviewed the changes and verified them locally.

Purpose of the pull request

Fix task kill status checking when kill -0 returns Operation not permitted for an unkillable sudo parent process or when tenant login shell emits stderr with exit code 0.

Closes #18311.

Brief change log

  • Add exit code accessor to ExitCodeException.
  • Distinguish alive, not-alive, and no-permission process states in ProcessUtils.
  • Continue killing permitted child processes instead of reporting success when only the sudo parent check is denied.
  • Add unit coverage for ExitCodeException and the sudo-parent-denied plus killable-child process scenario.

Verify this pull request

This change added tests and can be verified as follows:

  • ./mvnw -pl dolphinscheduler-common -Dspotless.check.skip=true -Djacoco.skip=true -Dtest=AbstractShellTest test
  • ./mvnw -pl dolphinscheduler-task-plugin/dolphinscheduler-task-api -am -Dspotless.check.skip=true -Djacoco.skip=true -Dsurefire.failIfNoSpecifiedTests=false -Dtest=ProcessUtilsTest test
  • ./mvnw -pl dolphinscheduler-common,dolphinscheduler-task-plugin/dolphinscheduler-task-api -DskipTests -Djacoco.skip=true spotless:check

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md.

zhuxiangyi avatar Jun 01 '26 23:06 zhuxiangyi

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

sonarqubecloud[bot] avatar Jun 02 '26 06:06 sonarqubecloud[bot]

@SbloodyS Could you review this PR for me?

zhuxiangyi avatar Jun 02 '26 11:06 zhuxiangyi

This repair way is not very good. The UI does not classify the result type of kill. If we want to do this, we should first discuss how to show this type to users in the UI, and then decide how to realize it. cc @ruanwenjun

@SbloodyS Thanks for the review. I agree that exposing kill result types to users should be discussed separately. This PR does not intend to introduce a new user-visible kill state. The main problem here is that the worker currently treats any exception from kill -0 as "process not alive", which can cause a false successful kill log while child processes are still alive.

I can narrow this PR to only fix the false process-alive detection and avoid introducing a user-visible kill result classification.

zhuxiangyi avatar Jun 03 '26 09:06 zhuxiangyi

I don't think this needs to be repaired separately. Since this case will only appear when the user has no authority, it is a small probability event and can be easily avoided before deployment.

SbloodyS avatar Jun 03 '26 09:06 SbloodyS

@SbloodyS Thanks for the review. I agree the kill-result classification (and how to surface it in the UI) deserves its own discussion, so I've narrowed this PR to a minimal, behavior-preserving fix and dropped the user-visible parts.

What remains is purely a false-negative in liveness detection: AbstractShell throws ExitCodeException whenever stderr is non-empty even if the exit code is 0 (e.g. the tenant login shell printing HISTSIZE: readonly variable warnings). Because isProcessAlive treated any exception as "not alive", the still-alive children were misclassified as terminated and the kill signal was never actually sent — hence All processes already terminated while ps showed the tree alive. The fix is one branch: kill -0 raising ExitCodeException with exit code 0 ⇒ alive. No change to kill semantics, no new user-visible state.

I've removed the NO_PERMISSION / return false for the root-owned sudo parent — that part touches kill-result semantics and I'll raise it separately. In #18311 it isn't needed anyway: once the tenant-owned children are killed, the sudo parent exits on its own.

zhuxiangyi avatar Jun 18 '26 16:06 zhuxiangyi