Skip to content

fix(k8s): retry kubelet dial failures when executing pod steps - #72

Open
wyhhai wants to merge 1 commit into
opensourceways:mainfrom
wyhhai:feat/exec-retry
Open

wyhhai wants to merge 1 commit into
opensourceways:mainfrom
wyhhai:feat/exec-retry

Conversation

@wyhhai

@wyhhai wyhhai commented Nov 12, 2026 •

Copy link
Copy Markdown

Background

Every step a kubernetes-novolume runner executes is delivered through k8s.Exec, which the apiserver proxies to kubelet:10250. Those calls were the only ones left with no retry at all after #64 added retryK8sApiCall for the auth preflight: execPodStep, execPodStepWithOutput and execCalculateOutputHashSorted each created a fresh k8s.Exec and awaited it exactly once.

On 2026-11-09 the HK CI node pool produced 28 job failures with exactly this signature:

Post "https://172.16.1.121:10250/exec/...": Internal error occurred:
error sending request for url (https://172.16.1.121:10250/exec/...):
dial tcp 172.16.1.121:10250: i/o timeout

These were not container failures: the failing steps were spread across eight different step types, both runner sets were affected, and the same nodes simultaneously timed out to CoreDNS (10.247.3.10:53) and to the apiserver ClusterIP (10.247.0.1:443). Node inspection ruled out conntrack exhaustion, disk, memory, kubelet restarts and listen-queue overflows. The apiserver simply could not open a TCP connection to kubelet within its 30s dial budget, so the command inside the pod never started.

Changes

  • execPodStep, execPodStepWithOutput and execCalculateOutputHashSorted now run through retryExecCall: 3 attempts, 1s / 2s backoff.
  • Only dial-stage failures are retried. The new isExecDialError() matches the transport signature (dial tcp, i/o timeout, error sending request, no route to host, EHOSTUNREACH, ENETUNREACH, UND_ERR_CONNECT*) and explicitly refuses anything that already carries an exit code. Retrying a command that already ran would execute the step twice, which is worse than failing it once.
  • A script that exits non-zero keeps its existing semantics: execPodStep rejects, execPodStepWithOutput resolves with the parsed code, and neither is retried.
  • retryK8sApiCall is not reused here. It enforces a per-request timeoutMs (15s by default), which would kill legitimately long steps; exec keeps its native transport timeout instead.
  • execPodStepWithOutput / execCalculateOutputHashSorted were split into thin retry wrappers plus internal run* functions so the per-attempt buffers are rebuilt on every attempt and cannot accumulate across retries. Their public signatures only gained an optional trailing retryOptions parameter.
  • execCpToPod / execCpFromPod are untouched: they already have their own 30-attempt loops.

Tests

npm install --prefix packages/hooklib && npm run build --prefix packages/hooklib
npm install --prefix packages/k8s
npx tsc --noEmit -p packages/k8s
npx jest --config packages/k8s/jest.config.js tests/exec-retry-test.ts tests/exec-pod-step-with-output-test.ts --runInBand
npx eslint packages/k8s/src/k8s/index.ts packages/k8s/src/k8s/utils/index.ts packages/k8s/tests/exec-retry-test.ts

packages/k8s/tests/exec-retry-test.ts adds 11 cases: dial-timeout detection (including a message that carries both a network-looking string and an exit code), retry-then-succeed for all three exec entry points, no-retry on non-zero exit, no-retry on unrelated failures such as container not found, and the retry budget being exhausted when kubelet stays unreachable.

Scope note

This does not fix the underlying network fault — it converts a hard 35s failure into a retry that rides through a transient window, exactly like #64 and #71 did for the other API paths. A sustained outage longer than the 3-attempt budget still fails the step, as it should.

This PR is based on main and will conflict lightly with #71 in packages/k8s/src/k8s/index.ts (import block and helper area only); either can land first.

Related

resolve https://github.com/opensourceways/ascend-ci-deployment/issues/2638 — cluster-side evidence for the 28 HK-001 exec timeouts.

@opensourceways-bot

Copy link
Copy Markdown

Welcome To opensourceways Community

Hey @wyhhai , thanks for your contribution to the community.

Bot Usage Manual

I'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 Guide

If you have any questions, please contact the SIG: infratructure ,
and any of the maintainers: @GeorgeCao-hw, @TangJia025, @pkking, @zhongjun2 ,
and any of the committers: @GeorgeCao-hw, @Goalina, @Hourunze1997, @JavaPythonAIForBAT, @KadenZhang3321, @LiYanghang00, @ccijunk, @drizzlezyk, @pkking, @rosecoffe, @tfhddd, @yao-xiaobai, @zhongjun2, @zkhzkhz .

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Guide

@wyhhai , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
04914d45 fix(k8s): retry kubelet dial fai... the email used in the commit is an invalid email!
please check all commits.

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 /check-cla to revalidate CLA status.

@opensourceways-bot

Copy link
Copy Markdown

Linking Issue Notice

@wyhhai , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

@wyhhai

wyhhai commented Nov 12, 2026

Copy link
Copy Markdown
Author

/check-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants