Repository navigation
fix(k8s): fail the step when the exec stream dies before a terminal status - #74
KadenZhang3321 wants to merge 2 commits into
Conversation
…tatus Stacks on #72 (feat/exec-retry): #72 retries failures that happen while *dialing* the kubelet, before the command starts. This covers the other half — a stream that dies *after* the command started — which #72 must not retry. A step's result is taken from the single terminal V1Status frame the apiserver writes on the exec status channel, and client-node installs no 'close' or post-open 'error' handler for the exec socket. When that exec stream is torn down by an intermediary (an idle proxy/edge timeout while a long step sits quiet, e.g. loading model weights), the hook cannot tell a real completion from a severed session: it either hangs until the step timeout, or reports Success for a command that never finished — a silently green job whose test cases did not run. Inside each (already retry-wrapped) exec attempt: - keep the connection alive with a periodic WebSocket ping, so a quiet output window no longer looks dead to whatever sits between the runner and the apiserver; - treat a socket close/error that arrives *before* a genuine terminal status as a hard failure, never as success; - a pong that never arrives past the deadline is likewise a failure. Guard rejections use a dial-pattern-free message so retryExecCall classifies them as "already started" and does not re-run the step. execPodStep and execPodStepWithOutput preserve every existing exit-code path. Tunables: ACTIONS_RUNNER_HEARTBEAT_PERIOD_MS / ACTIONS_RUNNER_HEARTBEAT_DEADLINE_MS. Adds WebSocketHeartbeat plus unit tests: heartbeat timing, the fail-closed path, no-retry on mid-run interruption, and a no-false-failure-on-clean-close regression.
Welcome To opensourceways CommunityHey @KadenZhang3321 , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature Guide@KadenZhang3321 , thanks for your pull request. The following commit(s) are not associated with a signed Contributor License Agreement (CLA).
To sign CLA, click here. To check if your email is configured correctly, refer to the FAQs. Once you've signed the CLA or updating your email, please comment |
|
|||||||||||||
Problem
A step that never ran to completion can be reported green. Observed on the
sglang
nightly-4-npu-a3 / run (0)partition (Ascend/sglang run 44082178620):the
Run teststep finished in ~6 min, the test process was still loading thefirst model's weights (
Multi-thread loading shards: 6%) when the stepstopped streaming,
execPodStepWithOutputreturned{"metadata":{},"status":"Success"}, and the partition was marked successful —even though
run_suite.pyprinted none of its completion markers(
End (i/..)/Test Summary/TIMINGS END).Root cause
For a
kubernetes/kubernetes-novolumerunner every step is delivered throughk8s.Exec, and the step's result is taken from the single terminalV1Statusframe the apiserver writes on the exec status channel:execPodStep/execPodStepWithOutputonly ever callresolve(resp.code || 0)whenresp.status === 'Success'.@kubernetes/client-nodev1.x resolves the exec websocket onopenand theninstalls no
closeand no post-openerrorhandler(
web-socket-handler.ts#connect). So once the connection is established, thehook has no independent knowledge of the session's real state. If the exec
stream is torn down mid-run by anything on the path between the runner and the
apiserver — most commonly an idle proxy/edge timeout while a long step sits
quiet (e.g. model-weight loading, which logs a line every several seconds) —
the hook either hangs until the step timeout, or treats a spurious terminal
frame as a genuine success: a silently green step.
This is a latent defect in the exec layer itself; it is independent of which
federation (Karmada) or placement the runner uses. What changed recently is the
exposure: long, quiet nightly suites now run as a single multi-minute
streaming exec across a wider pool, so the quiet window that severs the idle
stream finally lands inside a step.
Fix
Backport the intent of upstream actions#333
(
WebSocketHeartbeat) and make the step-exec paths fail closed:pingso a quiet output window no longerlooks like a dead connection to the proxy/edge on the path to the apiserver.
closes orerrorsbefore a genuine terminal status arrived, the step is failed, never
trusted as success.
pongthat never arrives past the deadline failsthe step as well.
execPodStep/execPodStepWithOutputkeep every existing exit-code pathintact (
Success→ 0,Failure/message exit code → parsed code,exec()rejecting with a non-zero message → parsed code). New tunables:
Relationship to #72 (dependency — read this)
This PR is built on top of #72 (
feat/exec-retry) and should be mergedafter it. The two are complementary and cover opposite sides of the same exec
channel:
before the command starts, so re-running is safe.
must never be retried (it would re-execute the step). The guard rejects
with a deliberately dial-pattern-free message, so
retryExecCall/isExecDialErrorclassify it as "already ran" and propagate the failureinstead of retrying.
Because both edit
execPodStep/execPodStepWithOutput, the diff againstmainalso shows #72's changes; the only new commit here is this fix. Once #72merges, retarget this to
main(or it rebases to a single clean commit).Tests
tests/heartbeat-test.ts— ping cadence, deadline only armed after the firstping, pong keeps it alive, pong-timeout → failure,
stop()clears all timers.tests/exec-pod-step-test.ts/tests/exec-pod-step-with-output-test.ts—socket closed/errored before a terminal status → step fails; Success then
clean close → still resolves (no false failure); a mid-run socket error that
looks like a dial failure is not retried (exec attempted exactly once).
exec-retry-teststill passes unchanged.Cluster-backed suites (prepare-job / run-container-step / e2e) are unaffected on
the success path and run in CI's kind cluster.
resolve https://github.com/opensourceways/ascend-ci-deployment/issues/2638