Skip to content

Label docker-daemon-death job truncation as infra for auto-retry - #109673

Merged
alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:groeneai/praktika-label-docker-daemon-death-infra
Aug 30, 2026
Merged

alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:groeneai/praktika-label-docker-daemon-death-infra

Conversation

@groeneai

@groeneai groeneai commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #109096

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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, so runner.py marks the job ERROR. That is a runner-host infrastructure event, not a test or code failure.

The hourly retry_infra_failures workflow re-runs jobs labeled infra, 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 infra when the exit code is 125 and the log tail contains both Error waiting for container: Canceled and grpc: the client connection is closing. Both appear together only when a live container's daemon connection is torn down mid-run. A deterministic Cannot connect to the Docker daemon at unix:///var/run/docker.sock regression 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 through set_label(), which stores {"name": "infra", ...}. retry_infra_failures.yml matches 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 no workflow scope is needed.

ci/tests/test_runner_docker_daemon_death_infra.py pins the detector in both directions and asserts on the persisted result JSON the retry workflow reads, including once end to end through _run with 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

  • Merged into: 26.9.1.382 (included in 26.9 and later)

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Runner._is_docker_daemon_death(exit_code, log_tail) is a pure function; the unit test feeds a real signature-A teardown tail (exit 125 + docker.sock EOF / grpc-context-canceled) and asserts detection on demand.
b Root cause explained? On a host docker-daemon death mid-run the main test container returns exit 125; the job is truncated (all executed tests OK) and runner.py marks it ERROR with only a generic "Job killed" info and no infra label. The hourly retry_infra_failures workflow re-runs only jobs whose result is labeled infra, so this class was never auto-retried and the merge check stayed red.
c Fix matches root cause? Yes. It sets Result.Label.INFRA exactly on the daemon-death truncation, which is precisely the label the retry workflow keys on.
d Test intent preserved / new tests added? New unit test ci/tests/test_runner_docker_daemon_death_infra.py (5 cases, both directions). No existing test weakened.
e Demonstrated both directions? Yes: detects daemon-death (exit 125 + signature) AND does NOT label a genuine test failure that exits 125, a non-125 exit, or an empty log.
f General, not a narrow patch? The signature is a tuple of the three distinct daemon-death log markers, not the single line from one report; timeouts are explicitly excluded (they have separate handling).
g Generalizes across inputs? Detection guards on exit_code==125 and non-empty log; each of the 3 signatures is tested independently plus the negative cases (real FAIL, exit 1, empty/None).
h Backward compatible? Yes. Pure-additive: only adds an infra label on an already-ERROR truncated job. No format/setting/behavior change for passing jobs.
i Invariants preserved? Yes. Only touches the exit_code != 0 and not result.is_completed() branch; status stays ERROR, all other paths unchanged.

Session id: cron:clickhouse-worker-slot-0:20260707-151100

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @leshikus — could you review? Small praktika-runner change: label a job truncated by a host docker-daemon death (exit 125) as infra so the existing retry_infra_failures workflow re-runs it on a fresh runner. Complements #109096 (which fixed the 9000s timeout-cleanup-hang); this covers the genuine daemon-death truncation, ~107 such s3-storage job errors in 21 days, PR-only.

@leshikus

leshikus commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

The infra label written here won't trigger retry_infra_failures.yml: its jq is

(.ext.labels // []) | any(. == "infra")

but set_label stores each label as a dict {"name":"infra",...}, so . == "infra" never matches. Two fork-safe fixes (no workflow scope):

  • Store a bare string — append "infra" instead of the dict, so the element is "infra". All readers already accept strings (_label_name, json.html normalizeLabels, gh.py's isinstance(item, dict) guards). Costs only the hover tooltip:
labels = result.ext.setdefault("labels", [])
if Result.Label.INFRA not in labels:
    labels.append(Result.Label.INFRA)
  • Or fix the check — any((.name? // .) == "infra"), which normalizes both dict and legacy-string forms. Needs workflow scope on the yml.

Otherwise this labels correctly but stays a no-op end-to-end.

@leshikus

leshikus commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

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

@groeneai
groeneai force-pushed the groeneai/praktika-label-docker-daemon-death-infra branch from ff8da86 to c0a07bb Compare July 7, 2026 17:45
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Confirmed, thanks. Verified the jq end to end:

  • {"ext":{"labels":[{"name":"infra"}]}} | any(. == "infra") -> false
  • {"ext":{"labels":["infra"]}} | any(. == "infra") -> true

So the dict entry set_label stores was a no-op against retry_infra_failures.yml. Adopted the bare-string fix (needs no workflow scope):

labels = result.ext.setdefault("labels", [])
if Result.Label.INFRA not in labels:
    labels.append(Result.Label.INFRA)

Readers all accept the string: Result._label_name returns the entry when it is a str; json.html normalizeLabels has an explicit typeof item === "string" branch; gh.py guards with isinstance(item, dict). Only cost is the hover tooltip, as you noted. Added a unit test pinning the stored element is "infra" and that any(. == "infra") matches it. Pushed.

@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. echo '{"ext":{"labels":[{"name":"infra"}]}}' | jq -r "(.ext.labels // []) | any(. == \"infra\")" -> false; with ["infra"] -> true. Reproduces the no-op on demand.
b Root cause explained? Result.set_label always stores {"name":"infra",...}. retry_infra_failures.yml matches with any(. == "infra"), which compares each element to the string "infra"; a dict never equals it, so the auto-retry never fires.
c Fix matches root cause? Yes. Append the bare string "infra" at the runner call site so the stored element IS "infra" and the jq matches. Chosen over editing the yml because that needs workflow scope (fork-unsafe; a prior dict-form yml fix was reverted for this reason).
d Test intent preserved / new tests added? Added test_infra_label_stored_as_bare_string_for_retry_jq pinning the stored element is "infra", that any(. == "infra") matches it, and idempotency. Existing signature-detection tests unchanged.
e Demonstrated both directions? Yes. dict -> jq false (broken), bare string -> jq true (fixed). All 6 unit tests pass.
f Fix general, not a narrow patch? Scope is this one runner truncation path. Other infra-label call sites (integration_test_job) have the same dict/jq mismatch but are out of scope for this PR; the general fix (change the jq or set_label globally) needs workflow scope and a broader review, so not bundled here.
g Generalizes across inputs? N/A (label-string plumbing fix, not a datatype/algorithm code path).
h Backward compatible? Yes. All label readers (_label_name, json.html normalizeLabels, gh.py dict guards) already accept both string and dict forms. Only loses the hover tooltip for this one label.
i Invariants/contracts preserved? Yes. ext["labels"] is a mixed str/dict list by existing contract (legacy string entries handled everywhere). Idempotent append guards against duplicates.

Session id: cron:clickhouse-worker-slot-4:20260707-174000

@leshikus leshikus added the can be tested Allows running workflows for external contributors label Jul 7, 2026

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok now

@clickhouse-gh

clickhouse-gh Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [af48dda]

Summary: ✅


AI Review

Summary

This PR teaches Runner to recognize the docker daemon died mid-run signature, persist a bare "infra" label so retry_infra_failures.yml can match it, and adds focused regression coverage around the detector and persisted result. The detector itself looks sound, but the fix is still incomplete for jobs whose non-blocking contract is only established inside complete_job: a daemon-death truncation is retried later, yet it still propagates as a blocking ERROR in the live workflow and can skip downstream jobs such as LLVM Coverage.

Findings
  • ⚠️ Majors
    • [ci/praktika/runner.py:356] The new contract here is “a daemon-death truncation is infrastructure and should be auto-retried instead of behaving like a real job failure”, but _label_infra_on_docker_daemon_death only mutates ext.labels. The live scheduler still keys off do_not_block_pipeline_on_failure / pipeline_status, so an amd_llvm_coverage shard that dies this way keeps pipeline_status=failure, which makes GitHub skip LLVM Coverage and leaves ready_for_merge red even though the failure was classified as infra. functional_tests.py only sets that non-blocking flag at complete_job time, which this truncation never reaches.
    • Suggested fix: propagate a scheduler-visible non-blocking or retry signal alongside the infra label, or predeclare the coverage shards' non-blocking contract somewhere the runner can preserve on truncated exits.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: make the daemon-death classification visible to the live pipeline scheduler for the affected non-blocking coverage jobs, not just to the hourly rerun workflow.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 7, 2026
Comment thread ci/praktika/runner.py Resolved
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]>
@groeneai
groeneai force-pushed the groeneai/praktika-label-docker-daemon-death-infra branch from c0a07bb to 78c88d7 Compare July 7, 2026 19:08
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Good catch. A plain Cannot connect to the Docker daemon at unix:///var/run/docker.sock regression also exits 125 with an unfinished result, and matching any single fragment (including the bare docker.sock) would auto-retry it forever instead of surfacing it.

Tightened _is_docker_daemon_death to require the cancellation-specific conjunction, dropping the docker.sock fragment entirely:

_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 docker.sock connect-failure (exit 125) and either cancellation marker alone are both NOT classified as infra. Pushed 78c88d7.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jul 7, 2026
@groeneai

groeneai commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. _is_docker_daemon_death(125, "<Error waiting for container: Canceled ... grpc: the client connection is closing>") -> True; with Cannot connect to the Docker daemon at unix:///var/run/docker.sock (exit 125) -> False; either marker alone -> False. Pinned in the unit test.
b Root cause explained? The prior signature matched ANY single fragment (incl. bare docker.sock). A deterministic docker-connectivity regression also exits 125 and leaves the result unfinished, so it matched docker.sock and got auto-retried forever instead of surfacing the real regression.
c Fix matches root cause? Yes. Require the cancellation-specific conjunction (Error waiting for container: Canceled AND grpc: the client connection is closing) via all(...), and drop the docker.sock fragment. Both markers only co-occur on a live container whose daemon connection is torn down mid-run.
d Test intent preserved / new tests added? Yes. Added test_plain_docker_sock_connect_failure_is_not_infra and test_single_cancellation_marker_alone_is_not_infra (negative); kept the positive full-line and bare-string-storage tests. 8/8 pass.
e Both directions demonstrated? Yes. Full cancellation line -> labeled infra; plain docker.sock connect-failure and single markers -> NOT labeled.
f Fix is general across code paths? Single detection point (_is_docker_daemon_death), one caller. No sibling path.
g Fix generalizes across inputs? N/A (CI-infra Python log-signature classifier, not a code bug).
h Backward compatible? Yes. Narrows classification (fewer false-positive retries); fork-safe, no workflow scope.
i Invariants and contracts preserved? Yes. Contract is exactly mid-run docker-daemon death; the conjunction enforces it. Timeouts still excluded; bare-string label still matches retry_infra_failures.yml jq.

Session id: cron:clickhouse-worker-slot-1:20260707-190400

groeneai added 4 commits July 30, 2026 17:30
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.
@groeneai

Copy link
Copy Markdown
Collaborator Author

The truncation this labels infra also fails ready_for_merge, and closing that needs a decision I do not want to take on my own.

Latest occurrence: Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) on #116619 at 68ed71ddaec1642018ae43ea5747c07c06eb110a (report). All 13,252 tests ran with 0 failures; the daemon went away 3.4 s into the post-test llvm-profdata merge of 22 profiles, so docker run returned 125. The chown fixup printed two lines later is not the cause: its return value is discarded at ci/praktika/runner.py:518, and exit_code comes from process.wait at :506. Breadth over 30 days, job-level error rows with no failing test row: 180 across 108 pull requests and 9 on master for Stateless tests (amd_llvm_coverage%, 54 for Integration tests (amd_llvm_coverage%.

Two things follow that this PR does not cover.

  1. Result.complete_job is the only writer of ext["do_not_block_pipeline_on_failure"] (ci/praktika/result.py:997), so the NOTE: LLVM coverage job - do not block pipeline - exit with 0 that ci/jobs/functional_tests.py:1499 prints is lost when the job is killed before it gets there. All 28 coverage test job configs carry allow_failure=False, while the bugfix-validation family pairs the same script-level declaration with allow_failure=True (ci/defs/job_configs.py:787, :1000).

  2. Setting allow_failure=True on those 28 is not sufficient by itself. HtmlRunnerHooks.post_run marks the dependent LLVM Coverage job DROPPED (ci/praktika/hook_html.py:224; the job log prints NOTE: Set job [LLVM Coverage] status to [DROPPED] due to current failure), and _finish_workflow fails ready_for_merge on any dropped result before it consults allow_failure (ci/praktika/native_jobs.py:1066 versus :1126). On the three shas whose Mergeable Check description named only a coverage job, result_pr.json has LLVM Coverage DROPPED on two of them, so only the third would have turned green.

So the open question is what an incomplete coverage measurement should do to the pipeline. Exempting the shards and letting LLVM Coverage run on upstream failure would let it publish a verdict from a short profile set, which is the error direction #115623 is currently fixing; leaving it as is means a host-level daemon death fails Mergeable Check on an unrelated pull request. I have a 10-line ci/defs/job_configs.py change and the measurements ready for either answer, and I would rather not land a competing mechanism next to #115623.

Comment thread ci/praktika/runner.py
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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. It does not close ready_for_merge. _finish_workflow never reads do_not_block_pipeline_on_failure (0 occurrences in ci/praktika/native_jobs.py, against has_label 4 and allow_failure 1 in the same file), and it appends a dropped result to dropped_results before it consults allow_failure. With the flag set the shard still lands in failed_results and Ready For Merge stays FAIL. Controls: an OK status, an issue label, and allow_failure=True each clear that same predicate.

  2. It would let LLVM Coverage publish a verdict from a shard whose container died mid-run, and it flips the artifact-upload gate at ci/praktika/runner.py:670 from 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.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 30, 2026
Merged via the queue into ClickHouse:master with commit 6038ecb Aug 30, 2026
181 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 30, 2026
pull Bot pushed a commit to erickirt/ClickHouse that referenced this pull request Aug 30, 2026
`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]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 31, 2026
…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]>
alexey-milovidov pushed a commit to UnamedRus/ClickHouse that referenced this pull request Nov 9, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors groeneai-origin-unknown PR origin: unclassified (legacy task) manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants