Repository navigation
Label docker-daemon-death job truncation as infra for auto-retry - #109673
alexey-milovidov merged 7 commits into
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260707-151100 |
|
cc @maxknv @leshikus — could you review? Small praktika-runner change: label a job truncated by a host docker-daemon death (exit 125) as |
|
The but
labels = result.ext.setdefault("labels", [])
if Result.Label.INFRA not in labels:
labels.append(Result.Label.INFRA)
Otherwise this labels correctly but stays a no-op end-to-end. |
|
fixing the jq to any((.name? // .) == "infra") would also start auto-retrying every other set_label-based infra site — notably the integration image-prefetch failure at integration_test_job.py:935, this may not be intended |
ff8da86 to
c0a07bb
Compare
|
Confirmed, thanks. Verified the jq end to end:
So the dict entry labels = result.ext.setdefault("labels", [])
if Result.Label.INFRA not in labels:
labels.append(Result.Label.INFRA)Readers all accept the string: |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-4:20260707-174000 |
|
Workflow [PR], commit [af48dda] Summary: ✅ AI ReviewSummaryThis PR teaches Findings
Final Verdict
|
When the host docker daemon dies mid-run, the daemon connection is canceled
while the main test container is still running: the container returns exit 125
and the job is truncated (all already-executed tests OK) but the run never
finishes, so runner.py errors it. This is a runner-host infrastructure event,
not a test or code failure, yet the job result carried only a generic
"Job killed" error and no infra label, so the hourly retry_infra_failures
workflow (which re-runs jobs whose result is labeled infra) never re-ran it and
the merge check stayed red.
Detect this on a truncated, non-timeout run and label the result infra so the
job is re-run on a fresh runner. Require the cancellation-specific conjunction
"Error waiting for container: Canceled" AND "grpc: the client connection is
closing", not any single fragment: a deterministic docker-connectivity
regression such as "Cannot connect to the Docker daemon at
unix:///var/run/docker.sock" also exits 125 and leaves the result unfinished,
but is a real regression that must surface rather than be auto-retried forever.
Both markers together only appear when a live container's daemon connection is
torn down mid-run. Timeouts are excluded (they have their own handling).
Append the bare label string "infra" rather than the {"name": "infra", ...}
dict that Result.set_label stores: retry_infra_failures.yml matches with
`(.ext.labels // []) | any(. == "infra")`, which only ever sees a plain
string, so a dict entry would leave the label a no-op end-to-end. All other
readers (Result._label_name, json.html normalizeLabels, gh.py) already accept
the string form; the only cost is the hover tooltip. This keeps the fix
fork-safe (no workflow scope needed). Add unit tests pinning the signature
detection (including a negative test for the plain docker.sock connect-failure
and for either cancellation marker alone) and the bare-string storage.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
c0a07bb to
78c88d7
Compare
|
Good catch. A plain Tightened _DOCKER_DAEMON_DEATH_LOG_SIGNATURES = (
"Error waiting for container: Canceled",
"grpc: the client connection is closing",
)
# ... all(sig in log_tail for sig in ...)Both markers together only appear when a live container's daemon connection is torn down mid-run. Added negative tests: the plain |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260707-190400 |
Resolve the ci/praktika/runner.py conflict against master's current structure: master moved the TeePopen block inside a try/finally for the new HostMetricsCollector and added the host_metrics ext key, which re-indented the whole exit_code != 0 branch by one level. Re-apply the infra-label hunk at the new indentation on top of master's version of the branch rather than restoring the pre-merge block. Both review constraints re-verified against current master: - @leshikus: the label is appended as the bare string Result.Label.INFRA (guarded by `not in labels`), not set_label()'s dict. master's .github/workflows/retry_infra_failures.yml still matches with `(.ext.labels // []) | any(. == "infra")` and set_label() still stores dicts, so the dict form would still be a no-op. jq 1.7 end-to-end: dict -> false, bare string -> true, absent -> false. All readers still accept the string form on master: Result._label_name (result.py:428), json.html normalizeLabels typeof-string branch (json.html:800), gh.py isinstance(item, dict) guards. - clickhouse-gh[bot]: _is_docker_daemon_death still requires the cancellation conjunction ("Error waiting for container: Canceled" AND "grpc: the client connection is closing") with the bare docker.sock fragment dropped, so a deterministic Cannot-connect-to-the-Docker-daemon regression (also exit 125, also unfinished) is not auto-retried forever. All 8 unit tests pass after the merge. Ran the whole ci/tests suite: 506 passed, 4 failed, and the same 4 fail identically on unmodified master (test_cleanup_kills_orphaned_test_process, both test_parallel_*_limit_exits_with_max_failures_code, test_print_sql_stacktraces_against_live_server) - pre-existing and host-environment dependent, not caused by this branch. Two black nits in the newly added code were fixed (collapsed the all() generator onto one line, wrapped the two-term if into parentheses); runner.py is now byte-identical to master's own pre-existing black baseline, and the test file is black-clean.
Gate B found the label test reconstructed the append logic instead of
invoking it, so deleting the whole wiring from _run left all 8 tests
green (verified by mutation). Extract the labeling decision into
Runner._label_infra_on_docker_daemon_death, call it from _run, and point
the tests at it.
The test file now also pins the cases the copied logic could not: the
label is idempotent, it appends rather than clobbering labels an earlier
step recorded (including the dict form other paths still write), a
timed-out run and a plain docker.sock connect failure are not labeled,
and _run still invokes the helper. Six mutations each redden exactly
their own row: dropping the _run call, making the helper a no-op,
storing the dict form, dropping the timeout exclusion, clobbering
existing labels, and weakening the conjunction to any().
The mixed case is what the retry workflow will actually see once another
step has labeled the result, and jq 1.7 confirms it end to end:
["infra"] and [{"name":"flaky"},"infra"] both match
`(.ext.labels // []) | any(. == "infra")`, [{"name":"infra"}] does not.
Gate B re-raised the liveness finding: the AST assertion proved only that _run contained a call with the helper's name, so it stayed green if the call passed an empty log, forced timeout_exceeded, or ran after the dump. All three were confirmed by mutation. Extract the whole result-finalization block into Runner._finalize_job_result (a line-for-line move, so _run's behavior is unchanged) and drive it in the tests with a fake process and a temporary Settings.TEMP_DIR. The assertions now read the persisted result JSON, which is the artifact retry_infra_failures.yml consumes, so the label's condition, its arguments and the dump ordering are all covered instead of the call's syntax. Mutation results, each reddening test_run_persists_bare_infra_label_on_ daemon_death unless noted: passing an empty log tail, forcing timeout_exceeded at the call, moving the labeling after result.dump(), dropping the call, and storing the dict form. Labeling unconditionally reddens the timeout and connect-failure test, and weakening the conjunction to any() reddens the single-marker test. The first three of those passed against the previous AST-only assertion. Also drops the now-unused `result` binding in _run (ruff F841) and wraps the dedented "Invalid status" f-string, which keeps runner.py at master's existing black baseline.
Gate B raised the liveness finding a third time: with the finalization block extracted, every behavioral assertion still entered through _finalize_job_result, so deleting _run's only call to it left the whole suite green. Confirmed by mutation, and the same gap one level up from the previous round. Add an end-to-end test that calls _run itself. With run_in_docker empty the runner executes job.command directly through TeePopen, so the job is a shell script that restores the RUNNING result a real truncated job would leave behind, prints the teardown tail, and exits 125. The assertion reads the persisted result JSON. Deleting _run's finalize call and wrapping it in a never-taken branch both now redden this test; they passed against the helper-level tests alone. The earlier mutations still redden their own rows: dropping the labeling call, storing the dict form, and weakening the conjunction to any(). ci/tests: 513 passed, and the 4 failures (orphaned-process cleanup, both max-failures-exit-code parallel cases, live-server stacktraces) fail identically with these two files reverted to master, so they are pre-existing and host-environment dependent. 20 repeats of this file are green, 300/300.
…h-infra Master added a utilization-labeling block inside the `if host_metrics:` branch of `Runner._run`; this branch had moved that same branch into the extracted `_finalize_job_result` classmethod. Ported master's block into the helper so both changes survive: the utilization hints keep using `set_label`, and the docker-daemon-death path keeps appending the bare `infra` string that `retry_infra_failures.yml`'s `any(. == "infra")` jq can actually match.
Master now classifies host metrics into utilization labels on the same result, so `ext.labels` legitimately holds `set_label` dicts next to the bare `infra` string, and their presence depends on the runner's load. Membership is also the exact property the retry workflow tests: its jq is `any(. == "infra")`, which a dict entry never satisfies. Storing the dict form still reddens this assertion, so the constraint the test exists to protect is unchanged.
|
The truncation this labels Latest occurrence: Two things follow that this PR does not cover.
So the open question is what an incomplete coverage measurement should do to the pipeline. Exempting the shards and letting |
| result.set_info(latest_log) | ||
| # Must run before the dump below, or the label never reaches the | ||
| # result JSON that retry_infra_failures.yml reads. | ||
| cls._label_infra_on_docker_daemon_death( |
There was a problem hiding this comment.
This only updates ext.labels, but the live workflow does not look at that field when deciding whether downstream jobs may run. HtmlRunnerHooks.post_run still treats the result as blocking unless do_not_block_pipeline_on_failure is set, and the amd_llvm_coverage shards only set that flag inside complete_job (ci/jobs/functional_tests.py:1365-1473), which a daemon-death truncation never reaches. So a shard classified here as infra still emits pipeline_status=failure, GitHub skips LLVM Coverage, and ready_for_merge stays red until the separate hourly rerun happens. If the contract is “infra instead of a real failure”, this needs a scheduler-visible signal as well, not just the retry label.
There was a problem hiding this comment.
Agreed on the fact, and it is the finding in my 07:44Z comment above with the same citations: Result.complete_job is the only writer of ext["do_not_block_pipeline_on_failure"], a container death never reaches it, so HtmlRunnerHooks.post_run and Runner._pipeline_status both still read the job as blocking. Measured on master a5c2615: with ext.labels = ["infra"] set, _pipeline_status returns failure and the dependee-dropping branch is still taken, identical to carrying no label.
I disagree that a scheduler-visible signal is the fix, on two measurements:
-
It does not close
ready_for_merge._finish_workflownever readsdo_not_block_pipeline_on_failure(0 occurrences inci/praktika/native_jobs.py, againsthas_label4 andallow_failure1 in the same file), and it appends a dropped result todropped_resultsbefore it consultsallow_failure. With the flag set the shard still lands infailed_resultsandReady For MergestaysFAIL. Controls: anOKstatus, anissuelabel, andallow_failure=Trueeach clear that same predicate. -
It would let
LLVM Coveragepublish a verdict from a shard whose container died mid-run, and it flips the artifact-upload gate atci/praktika/runner.py:670from false to true, uploading artifacts from a dead container. That is the error direction I named in that comment.
The window is bounded: retry_infra_failures.yml calls gh run rerun "$run_id" with no --failed, so the whole run reruns, and the truncated job leaves no cache record because one is pushed only if result.is_ok(). LLVM Coverage and ready_for_merge rerun with it. Before this PR the job was never retried at all.
What an incomplete coverage measurement should do to the pipeline stays the open question in that comment. It needs a maintainer decision, so I am not settling it here.
`ci/tests` and the `CI Tests` job that ran it were removed in ClickHouse#115650, which merged at 2026-08-30T00:35Z. ClickHouse#109673 merged eight hours later, at 08:41Z, from a branch cut before that removal, so it re-created the directory with the one file it carried: `ci/tests/test_runner_docker_daemon_death_infra.py`. Nothing runs it any more - the job, its config and its workflow lane are gone - and nothing references it by name, so it is dead code. Removing it finishes the removal rather than re-opening the decision. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…d run The hourly auto-retry in `retry_infra_failures.yml` has never acted on the `infra` label that ClickHouse#109673 added. Five independent defects sit in the same block, and all of them were measured on live runs. 1. A fork run carries no pull request number. GitHub populates `.pull_requests` only for a head branch in the base repository: it is populated for 0 of 33 sampled fork heads and for 7 of 7 same-repo heads. The whole Praktika-result path was gated on that number, so it was dead on every fork pull request. It is now resolved from the head reference when absent, which also revives the `Config Workflow` updated-description path for fork pull requests. 2. The job-name-to-filename normalization did not match praktika's. `Utils.normalize_string` ends with `res.rstrip("_")`, which the workflow's `sed` lacked, so every job name ending in a parenthesis built a key that does not exist: 155 of the 170 job names in the generated `pull_request.yml` mismatch. `curl -sf` treats the resulting 403 as a failure and the loop broke on the first one, so one failed parametrized job anywhere in a run killed the path. The construction is deleted rather than patched. 3. The failed-sub-result test compared `"failure"` and `"error"` against `Result.Status`, which is uppercase, so it was always false and any failed job with a readable unlabelled result was classified as infrastructure. Fixing only the URL would therefore have started rerunning genuinely failing runs; the two had to change together. 4. The label predicate matched only a bare string. `Result.set_label` stores labels as dicts, so the docker image pre-pull failure on integration jobs writes the dict form. `33b1f35c0ad` fixed exactly this and `7d022e880fef` reverted it across every workflow file, asking in its own description for the fix to be reapplied separately. One real artifact carries 191 dict labels beside 1 bare string, so both encodings must match. 5. The only available action was a whole-run rerun, which is correctly refused when the run also carries a real failure. All three runs that have ever carried the label are mixed, so 3 of 3 uses of the label were unrecoverable. The classification now reads the run's `result_pr.json` once. That is the same artifact `_finish_workflow` reads to compute `Mergeable Check`, so the retry decision and the merge decision can no longer disagree, and it is fresher than the per-job files. The job-level heuristic's own verdicts are deliberately not folded into that count: a `Run` step that fails in under two minutes is a timing proxy that also fires on a real fast failure such as `Style check`, so inside this path the artifact alone decides. Precedence between the two paths is asymmetric and unchanged: the artifact is read only when the heuristic has not already selected the run, so it can promote a candidate the heuristic rejected but never vetoes one it accepted. Each failed job gets a three-way verdict joined to the artifact by the entry's own `ext.run_url`: the S3 key names a pull request and a commit but no run, and 3 head commits in a 200-run sample carried two runs each, so the per-job join is what stops a candidate being classified from another run's entries. A single unclassifiable job abandons the whole candidate, because a re-run `Finish Workflow` returns early on an `OK` entry without consulting GitHub's own job conclusion and could otherwise post a green `Mergeable Check` over a real failure. A mixed run with exactly one infrastructure job now has that job rerun. GitHub's partial-rerun semantics are undocumented, so they were measured on a purpose-built probe: a per-job rerun re-executes the target, its dependents and `Finish Workflow`, carries every non-dependent job over with byte-identical timings and runner, and increments `run_attempt`; a second rerun with a previous attempt's job id is refused with 403 "Only jobs from the current attempt can be re-run". A job that had SUCCEEDED is re-executed if it depends on the target, but only 3 of the 170 generated jobs lack the `!contains(needs.*.outputs.pipeline_status, 'failure')` guard, so at most one job that could have passed is affected, and re-running the rest is the recovery rather than collateral. Exactly one job per run per tick, since the rerun makes every other job id stale. Two changes to existing behaviour. `Mergeable Check` is a commit status posted to the run's own head commit, and a rerun reuses the original event, so a run whose commit is no longer the head of its pull request can never unblock it; that precondition now applies to both actions rather than only to the `Config Workflow` path, which strictly reduces reruns. And a run sharing its commit with a concurrent run is left alone rather than acted on from a shared artifact. `MAX_RERUNS` and the candidate selector are untouched, so the tick's upper bound is unchanged. Validated with an uncommitted harness that extracts the step body from the YAML, driven over the 16 real pull-request-and-commit pairs that produced a `SQLLogic test` job-level failure in 30 days, beside the same harness running the unmodified step. The unmodified step takes no action on the mixed run 33331951492; this one reruns its single infrastructure job. The daemon death itself is a host condition, out of reach here: five distinct `m8g.4xlarge` hosts lost their daemon inside 36 minutes on 2026-08-30. Co-Authored-By: Claude Opus 5 <[email protected]>
…container exit A root (`+root`) job container publishes its final result with `Result.complete_job` -> `dump_atomically` (tmp file + `os.replace`, since ClickHouse#113200), so the result JSON in `ci/tmp` becomes a new root-owned inode. The server log dir under `ci/tmp` is created by root as well. The runner relies on the docker-based `chown -R` fix-up to give both back to the host user. When the docker daemon goes away together with the job container (CLI exit 125, "Error waiting for container: Canceled" + "grpc: the client connection is closing", the ClickHouse#109673 signature), that fix-up fails too (`docker.sock/_ping: EOF`) and its exit code was discarded. Then: - `_finalize_job_result` rewrites the root-owned result in place -> `PermissionError`, and the job is reported `exit code [None]`; - the log upload compresses next to the source in the root-owned log dir -> `Permission denied`, server logs are not uploaded; - with those fixed, the job would still be red: the CLI's 125 overrides the job's own completed OK verdict (`exit code [125]`, also seen on SQLLogic and tsan shards) and the `provides` artifacts are not uploaded. Changes: - When the docker chown fails, fall back to `sudo -n chown -R` on the host (`Runner._run` and the sibling `Utils.fix_ownership_after_docker` used by the stress and AST fuzzer jobs). `-n` fails fast where sudo is not passwordless, so such hosts behave as before. - `Result.complete_job` stamps `ext["completed_by_job"]` in the same atomic publish as the verdict. A setter can persist OK earlier (for example `integration_test_job.py` calls `set_success()` before the coverage merge, the late OOM scan and `complete_job`), so a persisted OK alone is not a final verdict. - `Runner._run` keeps an OK result published by `complete_job` when the exit is the daemon-death 125 and the job did not time out: `complete_job` exits 0 on an OK verdict and nothing runs after it, so 0 is the exit code the container would have reported. FAIL/ERROR verdicts, timeouts, incomplete results (still labeled `infra`) and a 125 without both markers are unchanged. Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/36384768039/job/108966719660 Report: ClickHouse#113201 (comment) Validated with throwaway probes (a docker shim that runs the job body as root and loses the daemon at exit), not committed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #109096
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
When the host docker daemon dies mid-run, the main test container returns exit code 125 and the job is truncated: every already-executed test is
[ OK ], but the run never ends, sorunner.pymarks the jobERROR. That is a runner-host infrastructure event, not a test or code failure.The hourly
retry_infra_failuresworkflow re-runs jobs labeledinfra, but this path recorded only a generic"Job killed, exit code [125]"and set no label, so such jobs were never retried and the Mergeable Check stayed red despite all tests passing.A truncated, non-timeout run is now labeled
infrawhen the exit code is125and the log tail contains bothError waiting for container: Canceledandgrpc: the client connection is closing. Both appear together only when a live container's daemon connection is torn down mid-run. A deterministicCannot connect to the Docker daemon at unix:///var/run/docker.sockregression also exits 125 unfinished, so requiring the conjunction keeps it red rather than retrying a broken runner forever. Timeouts keep their own handling.The label is appended as the bare string
"infra"rather than throughset_label(), which stores{"name": "infra", ...}.retry_infra_failures.ymlmatches with(.ext.labels // []) | any(. == "infra"), comparing each element to a string, so the dict form would never match and this would be a no-op end to end. The other readers (Result._label_name,normalizeLabels,gh.py) already accept strings; the only cost is the hover tooltip, and noworkflowscope is needed.ci/tests/test_runner_docker_daemon_death_infra.pypins the detector in both directions and asserts on the persisted result JSON the retry workflow reads, including once end to end through_runwith a no-Docker job that exits 125.#109096 fixed the sibling 9000s timeout-cleanup-hang. This signature caused 107 job errors over 21 days, all on PRs and 0 on master; one report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/109536/887a2f0e48f223cde20a674e2c9dac31cc8eb483/result_stateless_tests_amd_tsan_s3_storage_parallel_2_2.json
Version info
26.9.1.382(included in26.9and later)