Skip to content

CI: apply the runner free-space guard on macOS runners too - #113605

Merged
leshikus merged 13 commits into
ClickHouse:masterfrom
groeneai:macos-runner-free-space-guard
Oct 8, 2026
Merged

leshikus merged 13 commits into
ClickHouse:masterfrom
groeneai:macos-runner-free-space-guard

Conversation

@groeneai

@groeneai groeneai commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

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

Apply runner-init's free-space guard on macOS runners as well, so a host with less than 20 GiB free removes itself from rotation instead of failing unrelated tests with NOT_ENOUGH_SPACE.

Description

Fast test (arm_darwin) failed unrelated tests with Code: 243 ... not enough space. (NOT_ENOUGH_SPACE)
whenever a macOS runner's rootfs filled up, e.g.
https://github.com/ClickHouse/ClickHouse/actions/runs/35900670985/job/107415740044 (four tests, two of
them unable to reserve 1.00 MiB).

Root cause. The free-space guard in runner-init.py, check_post_run, returned on macOS before
running df, so a full macOS host kept taking jobs until a reservation failed in whichever test ran
next. On Linux the same guard raises and the host leaves rotation.

Change. The macOS early return now skips only the Docker teardown. The check moves into
check_free_disk_space and also runs from _check_conditions, so a host that boots still full never
registers. It reads the rootfs with shutil.disk_usage, the same statvfs fields df prints, so the
KiB and percent thresholds mean the same on macOS and Linux. On macOS the floor is 20 GiB, because a
Fast test job grows the rootfs by 2-4 GiB; Linux keeps 3,000,000 KiB and 5%. A refusal ends
runner-init with an Out of disk space: ... exception. config.version goes 77 -> 78.

No in-tree test: the guard is a threshold whose effect shows directly on the fleet.

Deploying: someone with the credentials must run --deploy per environment to upload version 78;
running macOS hosts pick it up between jobs through _exit_if_init_script_upgraded.


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

Version info

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

`Fast test (arm_darwin)` intermittently failed unrelated tests with
`Code: 243 ... Cannot reserve N MiB, not enough space. (NOT_ENOUGH_SPACE)`,
and sometimes truncated mid-run, because the macOS runners were exempted
from runner-init's free-space guard.

`check_post_run` opened with an unconditional
`if config.init_environment == Environment.MACOS: return`, so on macOS the
`df` never ran and `free_blocks_threshold` / `free_blocks_threshold_percent`
did not exist there. Those hosts are long-lived and are also exempt from the
`max_jobs` recycle, so their free space ratchets down across jobs until a
ClickHouse reservation fails on whichever test happens to be running. On
Linux the same guard raises, `run()` unregisters the runner, and the host
takes itself out of rotation.

The early return now guards only the Docker teardown, which is what
genuinely does not apply on these hosts and is most likely why the whole
function was short-circuited. The free-space check moves into
`check_free_disk_space` and is called from `check_post_run` and from
`_check_conditions`, so a host that boots still-full refuses the next job
rather than the one after it; that call deliberately sits above the macOS
early return in `_check_conditions`, since below it the check would be dead
on the only platform it targets.

`df` becomes `df -k` so one shared block threshold means 1 KiB everywhere:
BSD `df` reports 512-byte blocks by default, and GNU `df` also switches to
512 under `POSIXLY_CORRECT` or `$BLOCKSIZE`. On this 100 GiB pool the
percent bound binds above both block bounds, so `-k` changes no verdict
here; it matters on smaller volumes and against those environment
variables.

Thresholds are unchanged, and so is the recovery path: a macOS host drops
its provisioning marker and reboots rather than terminating, which is the
right disposition for a fixed-size dedicated-host pool with no autoscaling
group behind it.

`config.version` is bumped because the deploy path aborts unless the local
version is strictly greater than the one in S3, and because live hosts
re-run provisioning only when the version differs from their marker.

This bounds the damage without fixing the underlying leak: everything the
repository can reclaim already is reclaimed before each job, so the
accumulator is outside its reach and identifying it needs on-runner
measurement that nothing here collects.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: 1 major (evidence branch closed), 4 nits (all fixed). Click to expand.

I ran an independent cold review of the resulting code, then a second model reviewed it
without seeing my notes. One major and four nits; no code change was warranted, and every
nit was a correction to this PR's own description rather than to the diff.

⚠️ major: no checked-in regression test for the new macOS contract

Verdict: agreed on the evidence branch, declined on committing a test file.

The finding is disjunctive: add a focused test or provide reproducible evidence that a
low-space host raises before registration, check_post_run raises on macOS, healthy macOS
skips the Docker teardown, and Linux still runs it, with exact df -k / parsing asserted
at the threshold boundaries alongside the observable registration/cleanup calls. I took the evidence
branch and closed each named leg by driving the real module:

leg measurement
block bound, exact (40 GiB pool, where blocks bind) 2999999 -> raises Out of disk space: 2999999 blocks on rootfs; 3000000 and 3000001 -> no raise
percent bound, exact (the real 100 GiB pool) 4% -> raises 4% of free space on rootfs; 5% and 6% -> no raise
observable cleanup healthy macOS: teardown not invoked; production / staging / test: invoked, once each
observable ordering inside run's loop, _check_conditions is :317 and self.config() is :319, so the refusal precedes registration
parsing argv is ['df', '-k', '/'] in every cell

I declined the test file rather than judging it unnecessary. A 237-line harness added
here for a comparable runner-side change was deleted by a maintainer as an unneeded test,
and no commit touching this file has ever added one. I did check that a test would be
feasible and would discriminate (the module imports, boto3 is pinned in the ci_tests
image, ci_tests is triggered by a change to this path, and reverting the guard flips the
macOS cells from raising to silent), so this is a convention choice, not a limitation. The
PR body says so and offers the test; ask and I will add it.

💡 nits (all four fixed in the description, no diff change)

  1. The body implied no test was possible for a 6-line change. It is possible; reworded to
    name the convention and offer it.
  2. The "boots below the floor" caveat understated the loop by one step: configure_darwin
    runs before the check, and the macOS failure path drops the provisioning marker
    (:1042, pre-existing), so such a host reboots into a full re-provision. Now stated,
    together with the measured 97% -> 56% reclaim that bounds it to one cycle.
  3. Two cited line ranges were off by one against master (:407-408 -> :408-409 for the
    early return; :322-323 -> :323 for the max_jobs exemption). Corrected, and all
    citations re-verified against master, which is what a reviewer greps.
  4. The verification table claimed the 24-job threshold replay fires "on 99% and 97%". Only
    the 97% row is in that sample (the values run 97, 90, 69 ... 33); the 1.1 GiB / 99%
    figure comes from a different job and already had its own row. Corrected.

Checks that came back clean

df -k semantics verified locally on GNU coreutils 9.4: bare df equals df -k, while
POSIXLY_CORRECT=1, $BLOCKSIZE and $DF_BLOCK_SIZE each halve the unit and -k
overrides all three, the comment's claim is exact. The guard arithmetic was replayed
against the failing job's own df figures. -k can only report fewer free blocks than a
512-byte reading, so it cannot newly reject a healthy host. The change is one file, no
src/, no thresholds moved, and the comment budget holds (12 added code lines to 6 comment
lines, each stating a local invariant). Competing work: all 1879 open PRs swept; the one
touching a neighbouring file scores zero on every operation in this diff.

Session id: cron:clickhouse-review-slot-48:20260806-004200

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? No, and none was fabricated: the defect is a property of a reused macOS CI runner and no macOS host was available. In place of it, the two changed functions were driven directly with the free-space values measured from the failing job, which is deterministic: they raise at 3.4 GiB and 1.1 GiB free and stay quiet at 45 GiB.
b Root cause explained? Yes. check_post_run opened with an unconditional if config.init_environment == Environment.MACOS: return (:408-409), so on macOS the df never ran and free_blocks_threshold / _percent (:60-61) did not exist there. Those hosts are long-lived and also exempt from the max_jobs recycle (:323), so free space ratchets down until a reservation fails on whichever test is running. On Linux the same guard raises and the host unregisters via run()'s handler (:317-319).
c Fix matches root cause? Yes: it removes exactly that exemption and reuses the existing guard plus its existing failure primitive. No new policy, no new constants, thresholds untouched, recovery path untouched. It is not a band-aid: no bound is widened, no data reduced, no test tagged out.
d Test intent preserved / new tests added? No test is modified or weakened. No test file is added, matching this file's convention (no commit touching it has added one). A ci/tests test was measured to be feasible and discriminating, so this is a choice, not a limitation; the verification is reported in the description instead, and the test is on offer.
e Both directions demonstrated? Yes, to the extent possible without a macOS host. The guard raises on both measured full-disk values and stays quiet on the measured healthy one, at both call sites. Reverting the exact pre-fix line makes both raising cases stop raising, so the change is what produces the new behaviour.
f Fix is general across code paths? Yes: both call sites are covered (after a job and before accepting one), not just the reported one; all four Environment values are exercised (the enum has no LINUX member, so "Linux" is every non-MACOS value); the Docker teardown is explicitly scoped to non-macOS. Disclosed: the pre-job call is also Linux-visible, giving Linux the same check one job earlier.
g Fix generalizes across inputs? The input space here is df output and the environment. Covered: 1 KiB vs 512-byte block units measured in both directions on a real df; POSIXLY_CORRECT, BLOCKSIZE, BLOCK_SIZE and DF_BLOCK_SIZE all pinned by -k; four Environment values; free space at 1.1 / 3.4 / 45 GiB plus a 24-row sample spanning 33-97% used, and the exact off-by-one boundaries of both thresholds.
h Backward compatible? Yes. No setting, no serialization, no protocol, no SettingsChangesHistory.cpp. The one compatibility-shaped surface is the deploy version gate, which is why config.version is bumped 74 to 75; without that bump the deploy path aborts on local <= remote and the change could never reach a runner.
i Invariants and contracts preserved? Invariant: after every job, and before accepting one, a runner below the free-space floor removes itself from rotation instead of accepting more work, on every platform. Thresholds and both RuntimeError messages are unchanged; _check_conditions's existing total_errors check still fires first; the Docker teardown still runs on every non-macOS environment; Monitor.check_are_both_alive() still runs after check_post_run on the non-raising path, and on the raising path it is short-circuited exactly as it already was on Linux.

Session id: cron:clickhouse-impl-slot-7:20260805-234400

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @leshikus @Algunenano, could you review this? The post-job free-space guard in runner-init opened with an unconditional macOS early return, so those long-lived hosts never ran the df and kept serving jobs on a nearly-full rootfs until reservations failed with NOT_ENOUGH_SPACE on unrelated tests; this scopes the early return to the Docker teardown and also runs the check before accepting a job.

@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label Aug 6, 2026
@Algunenano Algunenano self-assigned this Aug 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fb1501d]

Summary: ✅


AI Review

Summary

This PR makes runner-init.py enforce the low-disk guard on macOS too, raises the macOS floor to 20 GiB, and switches the measurement from parsing df to shutil.disk_usage. The direction is good, but the current head still leaves two serious gaps: the new pre-/post-job contract no longer has checked-in CI coverage, and low-disk ejections still emit no stable non-verbose signal for operators.

Findings

⚠️ Majors

  • [ci/praktika/infrastructure/runner/runner-init.py:250] The new pre-job refusal path is still unverified in checked-in automation. The current PR workflow at ci/workflows/pull_request.py:77 no longer includes any runner_init_e2e-style job, so the behavior added at ci/praktika/infrastructure/runner/runner-init.py:250 and the macOS/Linux post-job split at ci/praktika/infrastructure/runner/runner-init.py:473 are protected only by manual reasoning. That makes an important runner-lifecycle contract easy to regress unnoticed. Suggested fix: restore CI-wired dry-run / e2e coverage (or equivalent existing harness coverage) that drives the real script through the low-disk macOS pre-job refusal and the macOS-vs-Linux post-job paths.
  • [ci/praktika/infrastructure/runner/runner-init.py:462] Low-disk refusals are still not alertable on the default path. check_free_disk_space logs rootfs numbers only when config.verbose is set, then both low-disk branches raise immediately at ci/praktika/infrastructure/runner/runner-init.py:465 and ci/praktika/infrastructure/runner/runner-init.py:467. In production that turns repeated low-disk ejections into reboot / reprovision churn with only a traceback, which makes the underlying leak hard to detect before capacity is lost. Suggested fix: emit a stable non-verbose marker or metric just before raising, so operators can alert on recurring low-disk exits.
Final Verdict

⚠️ Needs changes before merge.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 6, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@leshikus The changes makes sense, but I don't think they solve anything since AFAIK they will be run only on "deployment" and not in every job. Can you have a look please?


# Must stay above the macOS early return below: a host that boots still
# full has to refuse the next job, not just the one after it.
Runner.check_free_disk_space()

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.

The new low-disk contract is still unverified in checked-in automation. Fast test (arm_darwin) does not schedule from runner-init.py, so the exact job this PR is trying to protect can stay skipped even if a later edit drops either this pre-job guard or the post-job one. Please add a small ci/tests regression that stubs subprocess.run / run_bash and asserts: low disk raises from _check_conditions() on macOS, check_post_run() still skips Docker on macOS, and non-macOS still does the teardown.

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.

@groeneai please implement the test which targets the functionality mentioned by the reviewer. Add a fixture/unit test only if the code under review contains a non-trivial algorithm - a rebase/resync loop, a version-ordering comparator, a parser - logic that can regress independently of I/O. For generic CI workflow glue - a sequence of checkout/commit/push/gh side effects held together by idempotency guards - do not add a fixture/unit test: it only asserts the order of mocked calls, testing the mocks, not behaviour, and breaks on any harmless reordering. Add a dry-run / e2e test wired into CI instead: run the workflow end-to-end, skip long operations (builds, uploads, real pushes/tags), and assert the step sequence. If the workflow already has a dry-run / e2e test, extend it rather than creating a new one. Ensure the test actually runs in CI - it appears in a CI job and executes on pull requests - not merely committed to the repo. See this issue for how to wire it.

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.

Done in ea6095c. A new Runner init E2E job runs runner-init.py unmodified on a faked host (instance metadata, boto3, df, sudo, bash, config.sh, run.sh) and asserts the step sequence of five scenarios: a macOS host below 20 GiB refuses before registering; a macOS job is followed by a disk check and no Docker teardown; a macOS host at exactly 20 GiB takes a job and leaves the rotation once it drops below; on Linux, exactly 5% free takes a job and tears Docker down, one block less refuses. Each of 14 edits to runner-init.py (either check removed, Docker teardown on macOS, <= in either guard, other bounds, ...) fails at least one scenario.

I used the dedicated-job shape from #116461: the CI Tests job behind shape 1 was removed in #115650 (merged 2026-08-30), so nothing on master runs ci/tests/ today, including test_e2e.py from #116460. The digest covers only runner-init.py and the job script, so other PRs reuse the cached result. It runs as root in clickhouse/style-test because the script writes /home/ubuntu/actions-runner, and it refuses to start outside a container.

I merged master first so the regenerated pull_request.yml does not conflict; please pull before your next push here.

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.

The new harness still does not verify the scenarios on CI. In ci/jobs/runner_init_e2e_job.py:361-362, main exits immediately when /home/ubuntu/actions-runner already exists, and the current Runner init E2E report fails exactly there with Refusing to run: /home/ubuntu/actions-runner already exists. Because the job never reaches run_scenario, the original request for checked-in automation coverage is still unmet.

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.

Correction: on ea6095c the job refused to start on the CI runner. The checkout there sits under /home/ubuntu/actions-runner, the runner home runner-init.py hard-codes, so an unisolated _cleanup_workspace would delete it. 193d880 runs each scenario in a private mount namespace with a scratch runner home, and the job passes: https://github.com/ClickHouse/ClickHouse/actions/runs/37681546939/job/112999424949

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.

The Runner init E2E coverage from 193d8804d046 is not in the current head anymore. The PR workflow in ci/workflows/pull_request.py:77 now goes straight from JobConfigs.style_check to JobConfigs.code_review.set_run_after(...), and there is no runner_init_e2e job left to exercise the new disk-guard paths in ci/praktika/infrastructure/runner/runner-init.py:250 and ci/praktika/infrastructure/runner/runner-init.py:473. So the original request for checked-in CI coverage is still unmet.

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

@Algunenano thanks for looking. I checked, and the guard does run per job, not only at deployment. But there is a real gap in what you raised, and it is in the uptake, not the execution.

Per job, twice. Runner.run's while True: (master :311) is _check_conditions (:313) -> config (:315) -> run_job (:316), and run_job ends with Runner.check_post_run() (:368). Each has exactly one call site, all inside the loop. Driving the real module over 3 jobs: _check_conditions 3, check_free_disk_space 6, check_post_run 3, argv == ['df','-k','/'] every time. The loop already shows this without my patch: run_job prints df -h per job at :331-332 ("Disk space before job"), unguarded on macOS. That print is where every number in this PR came from.

macOS is where the loop iterates most, which is why the missing guard mattered here: the max_jobs recycle is macOS-exempt (:322-323), so at the shipped max_jobs = 1 the real module stops after 1 job for production/staging/test but ran to my 12-job cap for macos.

Production, one host, one day (i-072b97ce1ddab2ba2, pre-job df from each job's own log): 94% -> 96% -> 97%, the 97% being the reported failure. i-06fc74def4e9f52d5 served 6: 80 -> 84 -> 85 -> 86 -> 90 -> 90. Provisioning-only checks could not produce those.

Replaying the first host's verbatim logged df lines through the patched guard: 94% / 6.0G is accepted; the next job's 96% / 4.9G raises Out of disk space: 4% of free space on rootfs before registration, the host unregisters via run()'s except Exception: self.remove_if_not_running(); raise, and the 97% job never starts. Both readings of the intervening state agree (96% pre-job, 97% "disk status after"), so it does not depend on where post-hooks sit relative to that print. Controls stay quiet: 6.0G and 44G free both no-raise, and across the sample only 96%+ fires (33/50/60/69/80/84/88/90/93/94/95% pass).

Where you are right. Nothing on a running host ever picks up a new version of this script: the loop body has no version re-check (get_remote_init_version, upload_init_script, configure_darwin, PROVISION_MARKER are all absent from it), as :221 notes for the short-lived Linux hosts. Uptake is: someone with the credentials runs --deploy to upload version 75 to s3://github-runners-data/cloud-init/macos.py, and each host picks it up only on its next boot, since user_data_macos.txt:48 re-downloads that object and :50 re-runs it under trap reboot EXIT (:10). Merging alone changes nothing on the fleet, and the repo names no owner for that step. The 74 -> 75 bump is what makes the upload possible at all (--deploy aborts on local <= remote).

df -k is worth keeping independently: BSD df reports 512-byte blocks by default, so the shared free_blocks_threshold = 3_000_000 (:60) would mean 1.43 GiB on macOS, below the 3.4 GiB at which this failed.

Happy to drop the pre-job call and keep this to check_post_run alone if you prefer the smaller change.

Resolves one conflict in `ci/praktika/infrastructure/runner/runner-init.py`
against @leshikus's concurrent work on the same file.

Both sides kept in `_check_conditions`: master's `_exit_if_init_script_upgraded`
call with its comment, and this branch's `Runner.check_free_disk_space` call
above the macOS early return. The placement is load-bearing - a host that boots
already full has to refuse the next job, not just the one after it.

`version` resolved to 76. The auto-merge produced 75, which is master's own
current value, and the upgrade machinery compares that integer: a running host
only re-provisions when the remote version is strictly greater
(`_exit_if_init_script_upgraded`), and `--deploy` aborts on
`config.version <= remote`. Leaving 75 would have made this script
indistinguishable from the one already published and the change could not ship.

The reported defect is still live on master: `check_post_run` there still
returns early on macOS before the `df`, so a macOS host at 97% used keeps
accepting jobs until a reservation fails with `NOT_ENOUGH_SPACE`.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ffb767792b5e7cb3c59d02eed5a29e3c9639963d

CI is fully finished on this head (Config Workflow, Style check, CI Tests, Code Review,
Build (arm_release), Finish Workflow and Mergeable Check all green; 169 jobs skipped by digest).
One failure, and it has an owner.

Check / test Reason Owner / fixing PR
Build profile diff / RuntimeError: No master baseline with build profile data found infra fail-close on a non-gating job, CI signal loss a fix task is created (investigating at full effort, fixing-PR link to follow on this PR)
CH Inc sync not started CH Inc sync (private, not actionable by me)

Not caused by this PR, which changes only
ci/praktika/infrastructure/runner/runner-init.py.

#115007 ("Anchor the Build profile diff master baseline windows on the run's own event", merged
2026-08-17) is deliberately NOT linked as the owner here, because it is measurably not a fix for this
failure. Checking the exact failing commit_sha of each recent carrier for walk_cutoff, the symbol
#115007 introduced:

carrier failing sha script lines walk_cutoff fix present
this PR ffb767792b5e 1466 0 no
#114397 ea0215bdb4f2 1466 0 no
#115607 debf21d45609 1543 2 yes, and it still failed twice on 2026-08-25

So the fix is present in a tree that produced this same traceback. Breadth over the last 4 days is
14 rows across 12 distinct PRs with 0 true-master rows.

Session id: cron:our-pr-ci-monitor:20260827-230000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Build profile diff: correction to the CI finish ledger on ffb767792b5e7cb3c59d02eed5a29e3c9639963d

Correcting my earlier ledger comment on this head. The Build profile diff row does have a fixing PR:

Check / test Reason Owner / fixing PR
Build profile diff / RuntimeError: No master baseline with build profile data found the baseline row filter was measured from the wall clock while the candidate chain is frozen at the run's own event fixing PR #115007 (mine, merged 2026-08-17)

My earlier statement that #115007 "is measurably not a fix for this failure" was wrong, and I am
retracting it.

Why the red is still here: this attempt is run_attempt = 3 of a run created 2026-08-07, and a re-run
replays the frozen tree, so it executes the pre-#115007 copy of the script. The traceback proves that
vintage on its own, naming line 1360 for the raise where master now has line 1427. That copy filters
baseline rows with date >= today() - 7, which on 2026-08-27 opens at 2026-08-20, while this run's
frozen master chain is anchored at 70eb05c2, committed 2026-08-07T11:37:56Z. Empty by construction.

What I checked before retracting. Over 30 days the signature has 18 distinct (PR, commit) pairs and 17
carry the pre-fix line numbers; the single post-fix one modifies this job's own baseline query, adding a
predicate on a column it introduces in the same change, so it is not a control for #115007. Conversely,
two re-runs whose tree does carry the fix, replayed 6.9 and 7.6 days after their event, both produced a
real comparison against the correct frozen baseline (d59f2be3, 0480d4ec).

Nothing in this PR causes this and it needs no change here: the row clears once this branch next picks
master up.

Session id: cron:clickhouse-plan-slot-0:20260827-231700

leshikus and others added 2 commits October 7, 2026 18:59
No metric filter reads the label, and runner-init output on macOS does not
reach CloudWatch: `ec2-macos-init` buffers user-data stdout until the script
exits. The refusal is already logged by `__main__` as
"Got exception Out of disk space: ..., shutting down", so raise directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A `Fast test (arm_darwin)` job grows the rootfs by 2-4 GiB net and fails with
`NOT_ENOUGH_SPACE` when it starts with 3.6 GiB free, so the 2.86 GiB bound
let a nearly full host take the job. Raise the bound to 20 GiB on macOS only:
the check now also runs before every job, and Linux pools with small root
volumes must not refuse every job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai and others added 7 commits October 7, 2026 19:09
`runner-init.py` itself runs unmodified as `__main__` against a faked
host: instance metadata through `http_proxy`, a stub `boto3`, and fake
`df`, `sudo`, `bash` and actions-runner `config.sh` / `run.sh` that only
append to an event log. Nothing is provisioned, registered, uploaded or
terminated. Five scenarios assert the recorded step sequence: a macOS host
below 20 GiB refuses before registering, a macOS job is followed by a disk
check and no Docker teardown, a macOS job that leaves the host below the
bound ends the loop, a Linux host with 10 GiB free still takes a job and
tears Docker down after it, and a full Linux host refuses and terminates.

The `CI Tests` job that ran `ci/tests/` was removed in ClickHouse#115650, so this is
a dedicated job in the PR workflow. Its digest covers only `runner-init.py`
and the job script, so it is cache-reused unless one of them changes. It
runs as root in `clickhouse/style-test` because the script writes the
runner home `/home/ubuntu/actions-runner`, and it refuses to start outside
a container.

Each of these edits to `runner-init.py` fails at least one scenario: no
pre-job disk check, Docker teardown on macOS, no Linux teardown, no 20 GiB
macOS bound, keeping the provisioning marker on exit, no post-job check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The macOS floor is now exercised on both sides of it: a host with exactly
20 GiB free takes a job, and the same host refuses once the job has used
one block. The Linux refusal case has 4 GiB free on the 100 GiB volume, so
only the 5% bound can reject it, and the expected output names the bound
that fired. With these, raising the macOS floor to 24 GiB, lowering it to
19 GiB, or dropping either the block or the percentage guard now fails a
scenario. The step list in the report is capped at 20 entries, since a
runner that never leaves the loop otherwise produces megabytes of it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Linux job scenario now starts with exactly 5% free and the refusal
scenario with one block less, so a non-strict comparison or any other
percentage threshold fails one of them, as the 20 GiB macOS pair already
does for the block bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a CI runner the checkout is `/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse`,
and praktika mounts it at the same path in the job container, so the runner
home that `runner-init.py` hard-codes is the checkout's parent. The job
refused to start there, which is what it should do: unisolated,
`_cleanup_workspace` removes `_work`, and in that layout a run deleted
every file of a scratch checkout.

Each scenario now copies the script out of the checkout and runs it under
`unshare --mount` with a scratch directory bind-mounted over the runner
home, so the real one is not reachable from the script. That needs
`CAP_SYS_ADMIN` and an unconfined AppArmor profile in the container.
Verified with a scratch checkout mounted at the CI path: five scenarios
pass and the checkout is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The job faked instance metadata, `boto3`, `df`, `sudo` and `config.sh`, so
the disk numbers it asserted on were its own fixtures. The guard is a
threshold whose effect shows directly on the fleet; it needs no harness.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`shutil.disk_usage` reads the same `statvfs` fields `df` prints (available
and total), so the KiB and percent thresholds keep their meaning, and the
BSD/GNU `df` block-size difference no longer matters.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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 good

@leshikus
leshikus enabled auto-merge October 8, 2026 10:19
@clickhouse-gh
clickhouse-gh Bot requested a review from leshikus October 8, 2026 10:19
@leshikus
leshikus added this pull request to the merge queue Oct 8, 2026
Merged via the queue into ClickHouse:master with commit 08480e8 Oct 8, 2026
152 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 8, 2026
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-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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.

5 participants