flake: TestTasksCreate (multiple variants)
还没有人认领这个 Issue。
评估
调研方向
从 coderd/aitasks_test.go 中的 TestTasksCreate 开始,重点查看 1719-2130 行附近的 setup 和 CreateTask 调用。运行 go test ./coderd -run '^TestTasksCreate$' -count=100,最好在 Windows 上或增加 contention 的情况下运行,并验证所有变体都能在没有 context deadline failures 的情况下完成,同时其现有 assertions 仍然通过。
由索引模型根据 Issue 内容生成。
描述
CI failure
- CI run: https://github.com/coder/coder/actions/runs/30976975074
- Failing job: https://github.com/coder/coder/actions/runs/30976975074/job/92212913393 (
test-go-pg (windows-2022)) - Failure date: 2026-08-05 05:15 UTC; job completed at 05:21 UTC, before the 05:29 Slack alert
- Run attempt: 1
- Commit:
7a4ae2649eb592b961c142caf43dbe064a15a308 - Commit author: Jake Howell
The complete 4,462-line Windows job log was available and reviewed. The macOS matrix job was canceled only after this Windows job failed; this is not a matrix-cancellation artifact.
Failure evidence
Seven TestTasksCreate variants failed at the same API call with the same expired request context:
=== FAIL: coderd TestTasksCreate/TaskTableCreatedAndLinked (17.07s)
aitasks_test.go:1968:
Post "http://127.0.0.1:52750/api/v2/tasks/me": context deadline exceeded
=== FAIL: coderd TestTasksCreate/OK (17.13s)
aitasks_test.go:1751:
Post "http://127.0.0.1:52230/api/v2/tasks/me": context deadline exceeded
=== FAIL: coderd TestTasksCreate/MultipleTasksForSameUser (17.08s)
aitasks_test.go:2060:
Post "http://127.0.0.1:52756/api/v2/tasks/me": context deadline exceeded
=== FAIL: coderd TestTasksCreate/FailsOnInvalidTemplate (17.07s)
aitasks_test.go:1936:
expected: *codersdk.Error
in chain: Post "http://127.0.0.1:52831/api/v2/tasks/me": context deadline exceeded
=== FAIL: coderd TestTasksCreate/TaskWithCustomName (17.08s)
aitasks_test.go:2026:
Post "http://127.0.0.1:52697/api/v2/tasks/me": context deadline exceeded
=== FAIL: coderd TestTasksCreate/TaskLinkedToCorrectTemplateVersion (17.13s)
aitasks_test.go:2122:
Post "http://127.0.0.1:52747/api/v2/tasks/me": context deadline exceeded
=== FAIL: coderd TestTasksCreate/FailsOnNonTaskTemplate (17.26s)
aitasks_test.go:1906:
expected: *codersdk.Error
in chain: Post "http://127.0.0.1:52830/api/v2/tasks/me": context deadline exceeded
All template-version build jobs completed successfully immediately before the failing CreateTask requests. This is one synchronized test-family timeout, not seven independent product failures.
Root cause assessment
Classification: flaky test / timing-dependent deadline exhaustion on Windows.
Each failing subtest creates a 10-second context at the beginning of the test body:
ctx := testutil.Context(t, testutil.WaitShort) // WaitShort = 10s
It then performs expensive setup with that deadline already ticking:
- starts an in-process coderd and provisioner daemon;
- creates/logs in the first user;
- uploads a template version;
- waits for the provisioner import job;
- creates a template;
- only then calls
client.CreateTask(ctx, ...).
Under full-suite Windows load, setup consumed essentially the entire 10-second budget. The seven parallel variants consequently reached POST /api/v2/tasks/me with expired or nearly expired contexts and failed together after roughly 17.1 seconds of reported subtest time. Server logs show setup and template imports succeeding; there is no database outage or product panic.
A deterministic fix is to create a fresh request context immediately before CreateTask (and fresh contexts for later assertions), or use WaitLong for end-to-end variants whose setup is intentionally included in the deadline. The context should not be started before server/template setup.
Race, panic, OOM, and resource checks
The full job log contains no WARNING: DATA RACE, race detected during execution of test, panic/runtime-error trace, OOM, killed process, allocation failure, disk exhaustion, or file-descriptor exhaustion indicator. This was a normal assertion failure, not a process crash.
Assignment analysis
Ownership/history targets:
git blame -L 1719,2130 coderd/aitasks_test.go
git log --oneline -10 --follow coderd/aitasks_test.go
The most recent non-trivial modifier of TestTasksCreate itself is 30112075 (feat: add display name field for tasks, PR coder/coder#20856) by ssncferreira. That change substantially expanded the CustomNames portion of this exact function and retained the same early WaitShort context pattern. Later file changes either modify separate task tests or unrelated areas.
Assigning ssncferreira based on the failing test-function history, not the author of the CI commit.
Duplicate search
Searched open and closed coder/internal issues, including issues closed in the last 30 days, for:
TestTasksCreate,TasksCreate, and individual failing variants;api/v2/tasks/me+context deadline exceeded;aitasks_test.go, Windows task timeouts, andWaitShort;- database/timing errors, process crashes, panic/OOM/unknown failures, and race signatures.
No issue describes this exact test family and deadline-exhaustion mode.
Related but not duplicate:
- https://github.com/coder/internal/issues/1561 — CLI golden tests with broad slow-CI context deadlines, different package/test and setup path.
- https://github.com/coder/internal/issues/1600 — race-detector fallout involving
TestTasks/UpdateInput, different test and root cause. - https://github.com/coder/internal/issues/1320 — old
TestTasksrace-job report without thisTestTasksCreatesignature.
Reproduction
Most likely on Windows under full-suite parallel load:
go test ./coderd -run '^TestTasksCreate$' -count=100
To amplify locally, add delay or CPU/DB contention before CreateTask; the current context begins before all server and template setup.
- 主要语言
- 没有语言数据
- 星标
- 3
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/internal 的其他 Issue
-
chore: cleanup http transport debt可能已有人在做 @sreya 于 16 天前认领。 未关闭
-
难度 4/5 3-5 天 新手友好度 45/100
-
flake: TestPubsubCluster/ClusterAuthRequired可能重新可做 @sreya 于 67 天前认领,目前没有进行中的 PR。 未关闭flake
-
flake: TestSnapshotChanged_MultipleConfigFiles (multiple variants)可能重新可做 @Shelnutt2 于 86 天前认领,目前没有进行中的 PR。 未关闭
-
flake: TestPromoteChatQueuedMessage可能已有人在做 @DanielleMaywood 于 20 天前认领。 未关闭flake
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_wait未关闭needs-triage
难度 2/5 1-3 小时 新手友好度 77/100
krkn-chaos/krkn#1627 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
spring-projects/spring-grpc#442 ·
-
api: vertex-ai
难度 2/5 1-3 小时 新手友好度 72/100
googleapis/python-aiplatform#7208 · 1 条评论 ·
维护者通常 2 天内回复
-
ready
难度 2/5 1-3 小时 新手友好度 92/100
kubeflow/pipelines#14784 · 1 条评论 ·
维护者通常 2 天内回复