Skip to content

feat(k8s): retry transient k8s API failures in auth preflight; bump runner to 2.338.0 - #61

Open
KadenZhang3321 wants to merge 8 commits into
release-2.337.0-4e9113cfrom
feat/retry-k8s-api-calls-2.338
Open

KadenZhang3321 wants to merge 8 commits into
release-2.337.0-4e9113cfrom
feat/retry-k8s-api-calls-2.338

Conversation

@KadenZhang3321

Copy link
Copy Markdown
Collaborator

背景

vllm-ascend / sglang 等社区 CI 频发 Executing the custom container implementation failed(job 测试本身全绿,收尾/上传阶段连坐),排查结论见 ascend-gha-runners/docs#274。

定位到的机理:runner pod 经节点本地 ClusterIP 规则访问 in-cluster API(10.247.0.1),托管面 apiserver 后端每次轮换,该转发链路都会开出秒级窗口,三种形态随机:

形态 表现
规则瞬间无后端 connect ECONNREFUSED 10.247.0.1:443
规则指向过期后端 请求挂死(实测 6s+ 无响应)
打到未预热实例 403 selfsubjectaccessreviews ... is forbidden(重试即恢复)

而 hook 入口 isAuthPermissionsOK() 在每个 step 执行前都要跑 13 个并行、无 timeout、无重试的 SelfSubjectAccessReview,任一请求失败即 process.exit(1)。一个 job 上百次 API 触点,窗口命中变成必然。实测同一 token/同一请求在窗口内 200/挂死/403 随机,直连 apiserver 后端 IP 则始终正常——排除权限配置问题,纯瞬时窗口。

变更

  1. retryK8sApiCall(utils 新增,可复用):有限次重试 + 指数退避(3s/6s/12s×4 次)+ 单次请求 timeout(默认 15s,覆盖挂死形态)。仅重试瞬态错误:连接层错误码(ECONNREFUSED/ECONNRESET/ETIMEDOUT/UND_* 等)、消息签名、以及 HTTP 401/403/408/429/5xx(未预热实例的瞬时 forbidden 正是要跨过去的窗口);400/404/409 等确定性错误立即抛出,行为与原逻辑一致。
  2. isAuthPermissionsOK 接入重试;顺带修复原实现所有 13 个请求共享同一个可变 SAR 对象的问题——不修复的话,重试闭包重新序列化时会拿到外层循环最后一次赋值的 body(提交错误的 verb 组合)。
  3. Dockerfile:actions-runner 2.337.0 → 2.338.0。

效果

秒级窗口从「step 判死」降级为「warning + 多等数秒」。默认预算 4 次尝试 / 最长约 21s 退避,覆盖并远超实测到的窗口时长(1–6s)。

验证

  • npx jest tests/retry-utils-test.ts:9/9 通过(分类器 4 组 + 重试行为 5 组,含"超时弃挂起重试后成功"用例)
  • npm run build --prefix packages/k8s:tsc + ncc 通过,产物含新逻辑
  • eslint / prettier:新增代码 0 告警(仓库存量 7 个历史 lint error 与本次无关)

重跑窗口截图证据(故障窗口内 ClusterIP 路径):c200/c403/6s挂死 随机 → 窗口外同请求 240/240 全绿。

后续建议(不在本 PR)

  • 预检结果按 job 缓存(state 传递),免去每 step 重问 13 次
  • 重试逐步推广到 createJobPod / execPodStep / cleanup 的 API 调用

@opensourceways-bot

Copy link
Copy Markdown

Welcome To opensourceways Community

Hey @KadenZhang3321 , 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

@KadenZhang3321 , thanks for your pull request.

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

Commit Reason
a8f7515b feat(k8s): ride through transien... 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

@KadenZhang3321 , 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 .

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描 ✅
安全编码扫描 ✅
漏洞扫描 ❌
开源license合规扫描 ✅
UT测试覆盖率 ❌
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

- no-volumes file transfer (execCpFromPod/execCpToPod, execPodStepWithOutput)
- actionable error hints + fast-fail scoping for permanent errors
- null check for jobPod in runScriptStep; unify error format
- move k8s utils.ts to utils/index.ts for coverage gate

Includes upstream main changes up to 3f829ee (v0.8.0..3f829ee).
- add specs for k8s utils, exec-pod-step-with-output, run-container-step-terminated, run-script-step, wait-for-pod-phases
- move docker/hooklib utils.ts to utils/index.ts for coverage gate
- add Dockerfile building runner image with custom k8s hook
- bump dependencies, align package.json/lockfiles, jest setup
- update k8s README
- switch release workflow from workflow_dispatch to push tags v*
- enforce tag is on default branch
- enforce tag == package.json version
- add workflow_dispatch dry_run to validate build without creating a Release
- Dockerfile takes RUNNER_VERSION via build arg (no more hardcoded base)
- add .github/runner-versions.yaml as single source of base versions
- add build-image workflow building a matrix of runner versions
* ci: build and push multi-arch runner images to SWR on GitHub Actions

- replace Jenkins docker buildx pipeline with GitHub Actions
- matrix over runner versions from .github/runner-versions.yaml
- qemu + buildx multi-arch (linux/amd64, linux/arm64), provenance disabled
- tag images <runner-version>-<git-tag> on release, <runner-version>-<branch>-<sha> otherwise
- login to SWR cn-southwest-2 via SWR_AK / SWR_LOGIN_KEY secrets
- gha build cache

* ci: rename SWR secrets to SWR_USERNAME / SWR_PASSWORD

* ci: use SWR_USERNAME as full username (secret already includes region prefix)

* ci: build test images from branch pushes (tag = <runner>-<branch>-<sha>)

- trigger on all branches (except dependabot) as well as release tags
- branch builds use mutable <runner-version>-<branch>-<shortsha> tags
- sanitize branch name for docker tag; cap length
- document release vs test image tagging in docs/RELEASE.md

* style: fix prettier formatting (7 files) so CI format-check passes

* ci: make runner image build manual-only (workflow_dispatch)

- remove push (branch/tag) triggers to avoid wasted resources and image tag clutter
- default runner_version = latest in runner-versions.yaml; image_tag defaults to <runner>-<branch>-<sha>
- update docs/RELEASE.md

* fix(lint): resolve ESLint errors in fork-added/changed files

- add explicit return types (k8s/index.ts)
- rename shadowed 'pod' in run-container-step.ts
- drop unused callback param / use optional catch binding
- remove unused imports and spy variables in tests
- add eslint-disable for intentional unused signature param

All files are fork-added or fork-modified; no upstream-only files touched.

* chore: sync package-lock.json version with package.json (0.8.0-ascend.1)

Fixes CI 'Check linter' git diff --exit-code failure: npm install rewrites
the lockfile version field, which must match package.json.

* test: fix wrong separator assertion in run-script-step unit test

The implementation uses '-'.repeat(60) as the section separator
(see run-script-step.ts / run-container-step.ts), but the test asserted
the unicode box char '─'. Assert the actual separator instead.
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Guide

@KadenZhang3321 , thanks for your pull request.

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

Commit Reason
a8f7515b feat(k8s): ride through transien... the email used in the commit is an invalid email!
please check all commits.
26b0a6d8 Merge origin/main into feat/retr... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the 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 /check-cla to revalidate CLA status.

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

KadenZhang3321, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描 ✅
安全编码扫描 ✅
漏洞扫描 ❌
开源license合规扫描 ✅
UT测试覆盖率 ❌
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描 ✅
安全编码扫描 ✅
漏洞扫描 ❌
开源license合规扫描 ✅
UT测试覆盖率 ❌
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

@KadenZhang3321
KadenZhang3321 force-pushed the feat/retry-k8s-api-calls-2.338 branch from 0dab1c9 to 25f6887 Compare October 15, 2026 10:42
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

KadenZhang3321, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描 ✅
安全编码扫描 ✅
漏洞扫描 ✅
开源license合规扫描 ✅
UT测试覆盖率 ❌
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

…unner to 2.338.0

Runner pods reach the in-cluster API (10.247.0.1) through node-local
ClusterIP rules; every control-plane endpoint rotation opens a sub-second
window with three random shapes: ECONNREFUSED (no backend), request hang
(stale backend), and transient 403 on unwarmed apiserver replicas.

The hook entrypoint isAuthPermissionsOK() runs 13 parallel, untimed,
un-retried SelfSubjectAccessReviews before each step; any single failure
aborts the whole step (process.exit(1)).

- Add retryK8sApiCall: bounded retries with exponential backoff
  (3s/6s/12s, 4 attempts) + per-request timeout (15s); retries only
  transient errors (connection-layer codes, hang signatures, HTTP
  401/403/408/429/5xx); deterministic errors throw immediately
- Wrap the SAR preflight checks with retryK8sApiCall, and fix the shared
  mutable V1SelfSubjectAccessReview instance (now a fresh SAR per request)
- Register actions-runner 2.338.0 in .github/runner-versions.yaml
- Add tests/retry-utils-test.ts (classifier + retry behavior)
@KadenZhang3321
KadenZhang3321 force-pushed the feat/retry-k8s-api-calls-2.338 branch from 25f6887 to 47d6d96 Compare October 15, 2026 11:31
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

KadenZhang3321, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描 ✅
安全编码扫描 ✅
漏洞扫描 ✅
开源license合规扫描 ✅
UT测试覆盖率 ❌
开发阶段设计文档检查 ❌
流水线链接 点击跳转查看日志

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.

4 participants