Make Kubernetes job network readiness checks bounded and deployment-independent
维护者通常 1 天内回复
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- kubernetes, python
- 领域
- devops, infrastructure
调研方向
首先获取 maintainer 和 Kubernetes operator 对 readiness 策略及 timing 值的决定,然后检查 kernelci/kbuild.py 和 config/runtime/base/python.jinja2。添加使用 mock requests 和 waits 的针对性 unit 测试及模板渲染测试,并验证有界失败会被归类为基础设施错误;完成此项还要求在新启动的节点上执行一次 staging kbuild 运行,并在此处关联。
由索引模型根据 Issue 内容生成。
描述
Problem
KernelCI contains two startup workarounds for Kubernetes nodes whose networking or DNS may not be immediately ready.
KBuild._verify_network() performs an HTTP request to Google before generating the build script:
requests.get("https://google.com")
The current implementation has two failure modes:
- the request has no timeout and can hang indefinitely;
- a non-200 HTTP response does not decrement
retries, causing an infinite loop.
The generic Python job template contains a separate DNS workaround that resolves www.google.com up to 30 times before starting a job.
Both checks depend on an unrelated third-party service. Reaching Google does not prove that the KernelCI API, artifact storage, source repositories, or other services required by the job are reachable. Conversely, a Google outage or network policy blocking Google can prevent otherwise healthy KernelCI jobs from starting.
The HTTP check was originally introduced because networking could be slow to initialize on newly started Kubernetes nodes.
Relevant code
kernelci/kbuild.py:KBuild._verify_network()and its call fromwrite_script()config/runtime/base/python.jinja2: DNS readiness loop inmain()
ChromeOS/Tast-specific Google dependencies are being removed separately in #3196 and are outside this issue.
Desired outcome
Network initialization handling must:
- have a strict upper time limit;
- not depend on an unrelated public service;
- test connectivity relevant to the operation the job is about to perform;
- produce an actionable infrastructure error when readiness is not achieved;
- behave consistently between kbuild and other Python jobs.
Maintainer decision required
Before implementation, a KernelCI maintainer or Kubernetes operator should choose one of these strategies:
-
Retry the first required operation — recommended
Remove the generic preflight probes and apply bounded retry handling to the first real API, storage, source, or artifact request.
-
Use a configurable readiness target
Keep a preflight check, but provide the hostname or URL through runtime configuration. The default should be a KernelCI-controlled service required by the job.
The selected maximum startup delay, request timeout, and retry interval must also be recorded in this issue.
Implementation outline
After the strategy is confirmed:
- Remove both hard-coded Google readiness checks.
- Ensure every attempt has a connection and read timeout.
- Use a fixed attempt count or monotonic deadline so every failure path terminates.
- Handle expected network exceptions explicitly rather than catching every
Exception. - Avoid calling
sys.exit()from a low-level helper; return or raise an error that the job runner can classify. - Report exhausted network readiness as an infrastructure failure rather than a kernel build failure.
- Include the attempted service and elapsed time in the final error without exposing credentials or tokens.
- Add focused unit and template-rendering tests.
Required tests
Depending on the selected strategy, cover:
- immediate success;
- initial failures followed by success;
- DNS failure;
- connection timeout;
- read timeout;
- repeated non-success HTTP responses;
- retry exhaustion;
- enforcement of the maximum elapsed time;
- correct infrastructure-error classification.
Tests must mock network requests and waiting so they do not contact external services or introduce real delays.
Human participation required
This issue intentionally needs two concise operational checkpoints:
- A Kubernetes operator confirms whether delayed networking still occurs and approves the readiness strategy and timing values.
- After implementation, an operator runs a kbuild job on a newly scaled or cold Kubernetes node and links the result here.
Repository tests can prove that retry handling is bounded, but they cannot reproduce the real network initialization behavior of the production clusters.
Acceptance criteria
- Generic KernelCI startup code no longer uses
google.comas a connectivity probe. - No readiness or retry path can loop or block indefinitely.
- The total readiness wait is bounded by the maintainer-approved duration.
- Failure identifies the relevant unavailable service and is reported as an infrastructure error.
- Unit tests cover success, recovery, timeout, non-success response, and exhaustion.
- Generated runtime templates contain the selected bounded behavior.
- A staging kbuild job succeeds on a newly started Kubernetes node.
- The staging validation result is linked in this issue.
- Existing test and lint checks pass.
Out of scope
- Removing Google services that are required for an actual GKE or Google Cloud operation.
- Reworking unrelated download and upload retry policies.
- Changing Kubernetes cluster networking.
- Removing ChromeOS/Tast dependencies tracked by #3196.
- 主要语言
- Python
- 星标
- 120
- 派生
- 108
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 21
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
kernelci/kernelci-core 的其他 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 72/100
kernelci/kernelci-core#2591 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 25/100
kernelci/kernelci-core#3234 ·
维护者通常 1 天内回复
-
chromeos techdebt
难度 5/5 一周以上 新手友好度 35/100
kernelci/kernelci-core#3196 ·
维护者通常 1 天内回复
-
kubernetes runners missing logs and test naming wrong可能重新可做 @nuclearcat 于 71 天前认领,目前没有进行中的 PR。 未关闭
kernelci/kernelci-core#3170 · 2 条评论 · 1 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 20/100
kernelci/kernelci-core#3131 · 3 条评论 ·
维护者通常 1 天内回复
查看 kernelci/kernelci-core 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
mishraprafful/multihull#150 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
python-caldav/caldav#735 ·
维护者通常 1 天内回复
-
bug triage
难度 2/5 1-3 小时 新手友好度 68/100
mealie-recipes/mealie#8682 ·
维护者通常 1 天内回复
-
good first issue lane:repo
难度 2/5 1-3 小时 新手友好度 85/100