Skip to content

Preserve the previous cluster incarnation's docker.log when an integration fixture restarts - #119766

Merged
alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/preserve-docker-log-across-cluster-rebuild
Oct 11, 2026
Merged

alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/preserve-docker-log-across-cluster-rebuild

Conversation

@groeneai

@groeneai groeneai commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

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):

Integration tests keep the docker.log of a cluster incarnation replaced by a fixture restart.

Description

CI report (no related open issue found): Integration tests (amd_msan, 8/8), master 11f0dc83.

That job reported 13 FAILs, all azure parametrizations of test_storage_iceberg_with_spark, while 108 other azure parametrizations in the same job passed. Worker gw0's azurite emulator took a general protection fault inside musl (dmesg: traps: node[97065] general protection fault ... in ld-musl-x86_64.so.1, and its veth went down), so those tests ran 20 minutes against a dead blob endpoint. The emulator is third party and out of scope; replacing it is settled (#95967, reverted by #100618).

What is fixable here: the evidence was destroyed. A package-scoped fixture re-set-up inside one pytest session constructs a new ClickHouseCluster, whose constructor removes instances_dir, where docker.log lives. gw0's cluster was rebuilt 8 times, so logs.tar.gz shipped only the last incarnation: the collected docker.log starts 36 minutes after the last failure, on a different azurite port. That job built 61 incarnations across 7 projects and deleted 54. docker.log names the culprit: it carries every service prefix plus each container's exit code.

So this moves docker.log aside instead of deleting it, at both statements that delete instances_dir, into a sibling <instances_dir>-prev-logs/docker.<N>.log. The retention directory is cleared once per process, never per rebuild. Both log collectors already pick it up: the on-error hook by the _instances prefix, the normal path because it sits inside the failing suite's directory. norecursedirs = _instances* already keeps it out of pytest discovery. Cost: 7,945 bytes per incarnation. No ci/ scheduling or caching is touched, and no existing test changes. No dedicated test is added, because this changes the test infrastructure itself.

Not addressed: the musl fault; mid-package support-container liveness; earlier incarnations' per-node server logs, still deleted (retaining them measures ~2.7 GB per job, so that is your call); and the minio/kafka/rabbitmq failure-path dumps, which log the same compose project and duplicate the preserved file.


Workflow [PR]
Sync PR [sync-upstream/pr/119766]

Version info

  • Merged into: 26.10.1.2152-master (included in 26.10 and later)

groeneai and others added 2 commits September 13, 2026 09:05
A package-scoped integration fixture that is torn down and re-set-up inside one
pytest session constructs a new ClickHouseCluster, and the constructor removes
instances_dir. docker.log lives there and is reopened "w+" at the end of every
start(), so each rebuild destroys the previous incarnation's container output and
the exit code each container took.

On master 11f0dc8, Integration tests (amd_msan, 8/8) rebuilt gw0's cluster 8
times and reported 13 azure Iceberg FAILs from incarnation 1. logs.tar.gz shipped
incarnation 8: its docker.log starts 36 minutes after the last failure, on a
different azurite port, with nothing marking it as a different cluster. That job
built 61 incarnations across 7 projects and deleted 54. The trigger itself was a
general protection fault in the azurite emulator's musl loader, which docker.log
would have named directly through its container exit code.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=11f0dc839f845a3b866eddfd16360061f8bdeb2c&name_0=MasterCI&name_1=Integration%20tests%20%28amd_msan%2C%208%2F8%29

Move docker.log into a sibling <instances_dir>-prev-logs/docker.<N>.log before
both statements that delete instances_dir, the constructor and start()'s else
branch. The retention directory is cleared once per process, never per rebuild,
so a directory left behind by a previous process is discarded rather than filed
as this session's. Both existing log collectors already match the sibling because
its name still begins with _instances, and norecursedirs = _instances* already
excludes it from collection. 7,945 bytes per incarnation.

Co-Authored-By: Claude Opus 5 <[email protected]>
Two of the three rules the previous commit added were not actually exercised.

Every start() in the first version of the test followed a construction that had
just removed instances_dir, so start()'s existing-directory branch - the second
place that deletes it - was never reached. The test now restarts one cluster
object instead of only constructing new ones, which is also the shape that makes
--dist=each rebuild a module-scoped fixture.

The process-scoped clearing of the retention directory was equally unexercised: a
clean checkout has nothing to clear, so the assertion held with the whole clearing
branch deleted. The stale directory is now planted by the test itself, under
ordinal 9, so that renaming it rather than discarding it cannot satisfy the
ordinal assertions.

The retained bytes are compared in binary mode over the whole captured content
rather than as 200 decoded characters: two independent errors="replace" reads of a
file that is still being appended to decode a split multi-byte sequence
differently. The comparison stays startswith rather than equality because the log
follower is SIGKILLed without a wait(), so an in-flight write can still land
between the read and the move.

Finally, the cluster name is now unique per invocation, because the retention
directory is keyed by that name and pytest --count N repeats inside one process,
where the clearing fires only for the first repeat. Deriving the retention path
from get_instances_dir duplicates the naming in __init__, so the derivation is
pinned against cluster.instances_dir right after the first construction.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 13, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex). Round 1: 4 findings. Round 2, re-reviewing the fix round: 0 findings.

# Sev Finding Verdict Evidence / action
1 ❌ The zero-length guard in preserve_docker_log can still lose a previous incarnation's docker.log DISAGREE The scenario needs that incarnation's docker compose logs --follow to still be writing. shutdown SIGKILLs it (cluster.py:4499-4500) and a failed start does the same through its except path, so at start's carrier it cannot happen. In the one residual path, a raised teardown, the next start runs docker compose up on the SAME project name, so the later output belongs to the new incarnation and retaining it would mislabel incarnations. What the guard declines to move holds zero bytes
2 ⚠️ The new test fails deterministically under pytest --count N AGREE, fixed @ 9a7008c _CLEARED_PREV_LOGS_DIRS is per process, so repeat 2 found the retention directory populated. --count is documented in tests/integration/README.md:41,80,83. Each invocation now uses its own cluster name; --count 3 passes 3/3
3 ⚠️ The test never reached start's existing-directory carrier, never proved the stale-retention clearing, and compared only a 200-byte prefix AGREE, fixed @ 9a7008c The test now restarts one cluster object, so that carrier is exercised and dropping either preserve_docker_log call reddens; a stale docker.9.log is seeded, so the clearing is tested rather than assumed; the oracle compares the full captured bytes. Exact equality was rejected deliberately: the log follower is killed without a wait, so only startswith is append-safe
4 💡 The commit message omits the CI report URL AGREE, fixed @ 2de0737 .claude/CLAUDE.md:169
5 💡 My own draft description claimed an hdfs sub-directory docker.log, and called the sibling dumps the same class AGREE, corrected before publishing No code writes hdfs/docker.log; the minio/kafka/rabbitmq dumps are written only when that service fails to start, and compose_cmd scopes them to the same project as the preserved file

Also noticed and deliberately not changed: ci/jobs/keeper_stress_job.py:464 treats every _instances-* match as an instances directory, which is unreachable here because keeper cluster names carry a uuid4 suffix, so the new sibling never appears under tests/stress/keeper.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20260913-091400

@clickhouse-gh clickhouse-gh Bot closed this Sep 13, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [48d1771]

Summary: ✅


AI Review

Summary

This PR preserves a previous cluster incarnation's docker.log by moving it into a sibling retention directory before instances_dir is rebuilt. The idea looks sound for the --dist=each restart case it targets, but the current retention lifetime is keyed to the Python process rather than to a pytest run, so the documented pytest --count N mode can inherit retained logs from an earlier repeat and attach the wrong incarnation history to a later failure.

Findings

⚠️ Majors

  • [tests/integration/helpers/cluster.py:1133] _CLEARED_PREV_LOGS_DIRS is process-global, so the first cluster built in repeat 2 of the supported pytest --count N mode treats repeat 1's retention directory as current state. It preserves repeat 1's final docker.log into repeat 2's -prev-logs, which means a failure in the later repeat can upload docker.N.log from a previous top-level run rather than from a restart inside the current run.
    Suggested fix: scope the stale-retention clearing to a pytest run/repeat boundary, or add a per-run nonce to prev_logs_dir so only reincarnations of the same run share retention.
Final Verdict

⚠️ One major issue to fix before merge: retained docker.log history leaks across supported pytest --count repeats.

@groeneai
groeneai requested a review from fm4v September 13, 2026 09:50
@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Sep 13, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, I've deleted tests for the test infrastructure. Remember this decision.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Noted. I won't add tests for changes to the test infrastructure itself (integration test helpers, the test runner, CI scripts) from now on.

Comment thread tests/integration/helpers/cluster.py Resolved
qoega pushed a commit to qoega/ClickHouse that referenced this pull request Nov 19, 2026
… logs cluster outage

When the read-only sub-service of the CI logs cluster stops answering,
every `SELECT 1` readiness probe of `LogCluster.select` raises
`requests.exceptions.ReadTimeout`. `is_ready` turned that into a bare
False without a `probe_error`, so `select` raised `LogClusterNotReady`,
which `build_profile_diff_job.main` does not catch, and the check went
red on unrelated PRs (8 of them on 2026-11-06 between 00:00Z and 02:52Z,
e.g. job 127646247697 of ClickHouse#129611). The same outage hitting a POST already
ends `LogClusterUnavailable` (ClickHouse#121048), and so does a probe the server
rejects with 241 (ClickHouse#128067).

A probe that raises `ReadTimeout` now records `LogClusterUnavailable` in
`probe_error`, and the tail added by ClickHouse#128067 reports the read green as
"the endpoint never became ready: the readiness probe timed out: ...".
The last probe decides, as there.

A `ReadTimeout` (requests 2.33.0, the CI pin) is raised only after the
name resolved and a server accepted the connection: a stalled TLS
handshake or a stalled answer. Connection refused, an unresolvable name,
no SYN-ACK and a certificate mismatch raise `ConnectionError`
(`ConnectTimeout` and `SSLError` are subclasses), and the server itself
rejects a rotated password with 516. All of those, a missing secret and
a gateway answer still end `LogClusterNotReady`, as ruled on ClickHouse#120288.

This is the `SELECT 1`-timeout leg left open on ClickHouse#121048. Validated with
a throwaway harness against master (real sockets, mocked transport and
`main()` end to end); only the probe-timeout cases change. No test is
committed for the CI scripts (ClickHouse#119766).

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 comp-testing Test content only (no production code). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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.

3 participants