Skip to content

Print the macOS host's memory, swap and disk state in Fast test (arm_darwin) - #124316

Merged
alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:ci-macos-fast-test-print-host-state
Oct 7, 2026
Merged

alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:ci-macos-fast-test-print-host-state

Conversation

@groeneai

@groeneai groeneai commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122138
Related: #113605
Related: #121990

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

This PR adds diagnostics, not the fix: Fast test (arm_darwin) now prints what fills the macOS runners' disk.

On #122138, the job started with / 97% full (3.6G free), and 03312_squashing_with_low_card_mem_usage failed with Cannot reserve 317.82 MiB, not enough space. There were 7 such failures on 5 PRs and 3 hosts on 2026-10-06 (asked for in #122138 (comment)).

What grows is host state outside the job workspace: the same jobs leave almost nothing behind on some hosts and 0.6-0.75 GB per job on others, and only a reboot clears it. In the sampled job logs, ip-10-0-41-191 stayed above 50% from 2026-09-28 until it was full on 2026-10-06 (no reboot for 7 days), although #121990 gives macOS runners a 3-day lifetime. df prints one container-wide number for every APFS volume, so the existing df -h output cannot tell what grows.

ci/jobs/scripts/fast_test_darwin.sh now prints at job start and end: uptime, boot time, memory size, swap usage and memory pressure level; the provisioned and running runner-init versions; the swap files; Capacity Consumed per APFS volume; deleted-but-open files, each counted once, with a holding process; and the 10 largest processes by memory. At job start, when the data volume is at least 60% full, it also lists directories of 1 GiB or more. Every command is read-only; diskutil, lsof and du run under timeout and print their exit status, so a timed-out collector is visible. The job's exit code is still the test's.

Validation: a stub harness runs the real wrapper (also under bash 3.2 and BWK awk, as on macOS). It checks the exit code (0, 1, 137) with failing or hanging diagnostics, the printed collector statuses, the 60% gate and the output bounds. The wrapper is in the darwin job digest, so this PR's own CI prints the state of one host.


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

Version info

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

groeneai and others added 3 commits October 6, 2026 19:23
…win)

The macOS runners fill their 100G EBS boot container again (Code 243
NOT_ENOUGH_SPACE, e.g. job 112074232546 on ClickHouse#122138 started with / 97% full).
The job logs show the growth is host state outside the job workspace: the
same jobs leave almost nothing behind on some hosts and 0.6-0.75 GB per job
on others, and only a reboot (same instance id) resets a host to 43-45%. No
host went back to that level between 2026-09-28 and 2026-10-04, although
runner-init v77 (ClickHouse#121990) gives macOS runners a 3-day lifetime. GNU df on
APFS prints one container-wide number for every volume, so the existing
df -h output cannot say what grows, and the hosts cannot be inspected
directly.

Print, at job start (what earlier jobs left behind) and at job end: uptime,
boot time, memory size, swap usage, memory pressure level, the provisioned
and running runner-init versions, the swap files, Capacity Consumed per
APFS volume, deleted-but-open regular files with their holders, and the 10
largest processes by memory. At job start, when the data volume is at least
60% used, also list directories of 1 GiB or more (healthy hosts sit at
42-50%, so this only runs on a filling host).

Everything is read-only. diskutil, lsof and du run under GNU timeout (30,
60, 120 s; gnubin is first in the macOS job PATH), outside sudo so that
sudo's secure_path does not hide it; sudo -n never prompts; listings are
head-bounded. The test exit code is captured before the end call and the
teardown still always runs (no set -e).

The wrapper is in darwin_fast_test_digest_config, so a change to it runs
the job, and this commit's own CI samples one host. The fix for whatever
the output names follows separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A timed-out or refused `lsof` printed `0 files`, and a timed-out `du`
printed a partial list with no marker; print each collector's exit status
(124 = timed out).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lsof prints one row per descriptor, so a file held by several descriptors or processes was summed and listed more than once. Key the count, the total and the listing by device and inode, and also print the number of descriptors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 6, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 6, 2026
@groeneai

groeneai commented Oct 6, 2026

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

Pre-publication review by an independent model (engine: codex; 2 findings over 3 rounds, 0 in the last) plus my own cold review (5 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ A timed-out or failed lsof/du/diskutil looked healthy (0 files, or a partial du list with no marker) AGREE, fix round r1 each bounded collector now prints its exit status (124 = timed out)
2 ⚠️ The deleted-file summary counted descriptors, so a file held by several descriptors or processes was summed and listed more than once AGREE, fix round r2 count, total and listing are keyed by device and inode; the descriptor count is printed too
3 💡 PR text: "no host went back to 43-45%" is vacuous for hosts already at that level AGREE, fixed in the description states the measured ip-10-0-41-191 7-day case instead
4 💡 diskutil apfs list prints all three APFS containers (~45-60 lines) noted, not blocking host-configuration bound; the internal SSD container is useful too
5 💡 /tmp/runner-init.py may be absent on old hosts noted, not blocking the running version then prints empty; harmless
6 💡 lsof exit status 1 does not by itself mean a refused sudo noted, not blocking the raw status is printed as is
7 💡 1 (1 descriptors) wording noted, not blocking prescribed format; cosmetic

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-8:20261006-205300

@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The disk leak itself: no, it lives on CI hosts I cannot reach, which is why this PR adds diagnostics. The wrapper's behaviour: yes, a stub harness runs the real wrapper with stubbed sysctl/diskutil/lsof/ps/df/du on demand.
b Root cause explained? Not yet. Measured: host state outside the job workspace, cleared only by a reboot. Unknown: what grows, and each host's uptime. This PR turns both into job-log lines.
c Fix matches root cause? Diagnostics only. No speculative cleanup (purge, deleting swap files or shared temp dirs).
d Test intent preserved / new tests added? No test changed. The harness checks the wrapper's contract: exit code, teardown, gate, bounds.
e Both directions demonstrated? Yes. Eight mutations each turn a harness case red (start-only guard, end call before rc=$?, timeout 120, lsof and du status lines, counting rows instead of files, dedupe, device key). The real wrapper passes every case on bash 5.2 + gawk and bash 3.2.57 + BWK awk.
f Fix is general across code paths? Only Fast test (arm_darwin) runs on the macOS hosts, and this wrapper is its single entry point.
g Fix generalizes across inputs (params/datatypes/wrappers)? Failing, hanging (du, lsof, diskutil) and flooding diagnostics; gate at 59/60/97% used; empty lsof output; a deleted file held by several descriptors or processes, and the same inode number on another device; the 1 GiB du boundary; exit codes 0/1/137.
h Backward compatible? (maintainer-approved exception only) CI script only: no setting, format or runner-init change.
i Invariants and contracts preserved? The exit code is still fast_test.py's (rc=$? stays right after it; the end call runs after the teardown); the teardown always runs (no set -e added); every system scan is under timeout and prints its exit status; sudo -n never prompts; listings are head-bounded.

Session id: cron:clickhouse-impl-slot-7:20261006-203200

@groeneai
groeneai requested a review from leshikus October 6, 2026 21:10
@clickhouse-gh

clickhouse-gh Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [da4ffb4]

Summary: ✅


AI Review

Summary

This PR adds start/end host-state diagnostics to Fast test (arm_darwin) so the macOS runner leaks can be diagnosed from job logs. I found one blocker: the new diagnostics dump raw host-wide command lines and paths from a reused self-hosted runner into public PR logs, which can disclose unrelated workload details or secrets.

Findings
  • ❌ Blockers
    • [ci/jobs/scripts/fast_test_darwin.sh:32] The new host-state dump violates the boundary between jobs on a reused runner: ps ... command, the deleted-file listing, and the conditional du scan emit raw argv and filesystem paths for host-wide state that may belong to earlier or unrelated workloads, but the Fast test (arm_darwin) logs are public on PRs. That can leak workspace names, deleted filenames, and command-line secrets from another job or infrastructure process.
    • Suggested fix: keep the public log redacted/aggregated only (for example, process names via comm, counts and sizes instead of raw paths), or upload the detailed host dump to a private artifact that is not exposed in public PR logs.
Final Verdict

❌ Changes requested — please redact or privatize the host-wide ps / lsof / du details before merging this into the public PR workflow.

Comment thread ci/jobs/scripts/fast_test_darwin.sh Resolved
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 7, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 7, 2026
alexey-milovidov and others added 2 commits October 7, 2026 23:50
Address review: with `+L1`, `lsof` prints an `NLINK` column, so `$9` is the
inode `NODE`, not the first token of `NAME`. The dedup is already by device
and inode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged via the queue into ClickHouse:master with commit 7167867 Oct 7, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 7, 2026
local deleted lsof_rc
deleted=$(timeout 60 sudo -n lsof -nP +L1 2>/dev/null | awk '$5 == "REG"'; exit "${PIPESTATUS[0]}")
lsof_rc=$?
echo "$deleted" | awk -v rc="$lsof_rc" 'NF {d++} NF && !seen[$6 " " $9]++ {n++; s += $7} END {printf "open but deleted files: %d (%d descriptors), %.1f GiB (lsof exit status %d)\n", n, d, s / 2^30, rc}'

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.

ps -axm -o ... ,command here, together with the adjacent deleted-file and du dumps, sends raw host-wide argv/path data from a reused self-hosted runner into a public PR log. The whole point of this probe is to inspect leftovers from earlier jobs, so this can disclose unrelated workspaces, deleted filenames, or even command-line secrets from another workload on the same host. Please keep only aggregate data in the public log (counts/sizes, process names via comm, etc.) and move any detailed paths / argv to a private artifact instead.

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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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.

3 participants