Skip to content

CI: Route PR workflows to isolated runner fleet — zero-trust OSS CI, milestone 2 - #104870

Merged
maxknv merged 11 commits into
masterfrom
ci-pr-runner-label-prefix
May 24, 2026
Merged

maxknv merged 11 commits into
masterfrom
ci-pr-runner-label-prefix

Conversation

@maxknv

@maxknv maxknv commented May 13, 2026 •

Copy link
Copy Markdown
Member

This PR delivers the second milestone of the zero-trust OSS CI initiative: Praktika transparently routes all PR workflow jobs to the isolated pr-* runner fleet, without requiring per-job changes.

What's changed

Workflow.Config.runs_on_label_prefix — a new Praktika option that prepends a string to every runs_on label across all jobs in a workflow (user-defined jobs, and Praktika-injected jobs: Config Workflow, Dockers Build, Finish Workflow). The self-hosted label is left untouched.

The PR workflow sets runs_on_label_prefix = "pr-", so every PR job is automatically routed to the isolated pr-* fleet without any per-job annotation.

Build cache made read-only for PR jobs — untrusted PR code cannot write to the shared sccache/build cache consumed by trusted CI workflows.

Changelog category (leave one):

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

Note

Medium Risk
Moderate risk because it changes CI runner selection for all PR jobs and alters compiler-cache behavior, which can cause workflow scheduling or performance regressions if labels/fleet or cache expectations are misconfigured.

Overview
Routes the PR workflow to an isolated runner fleet by adding Workflow.Config.runs_on_label_prefix and applying it in praktika’s workflow mangling so every job’s runs_on labels are automatically prefixed (leaving self-hosted unchanged). The PR workflow sets this prefix to pr-, so generated PR jobs run on pr-* runners without per-job edits.

Hardens PR builds by making the shared sccache S3 cache read-only when Info.pr_number > 0, preventing untrusted PR code from writing to the cache used by trusted branches.

Reviewed by Cursor Bugbot for commit 9b30862. Bugbot is set up for automated code reviews on this repo. Configure here.

Version info

  • Merged into: 26.6.1.115

@maxknv
maxknv marked this pull request as draft May 13, 2026 16:12
@clickhouse-gh

clickhouse-gh Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9b30862]

Summary: ✅


AI Review

Summary

This PR adds runs_on_label_prefix to route PR jobs to pr-* runners, switches PR compiler cache writes to read-only, and updates runner infra tagging. The isolation objective is still violated because untrusted mac runners keep legacy trusted labels, and one previously dismissed status-handling issue remains in current code.

Findings

❌ Blockers

  • [ci/infra/cloud.py:18] Untrusted mac runners still keep legacy labels like amd_macos_m1 while also adding pr-*. MasterCI still schedules Smoke test (amd_darwin) on ['self-hosted', 'amd_macos_m1'] in ci/workflows/master.py, so trusted push jobs can run on the same fleet as untrusted PR jobs. This breaks the PR’s isolation contract for the pr-* fleet and leaves a trusted-on-untrusted execution path open.
    Suggested fix: on the untrusted PR fleet, advertise only pr-* labels; keep legacy labels only on a separate trusted fleet.

⚠️ Majors

  • [ci/jobs/scripts/workflow_hooks/check_report_messages.py:33] [dismissed by author -- https://github.com/CI: Route PR workflows to isolated runner fleet — zero-trust OSS CI, milestone 2 #104870#discussion_r3288721854] The hook still posts FAIL only and never posts explicit OK for the same Report messages context. On reruns of the same SHA, an earlier failing status is not cleared, so merge can remain blocked after warnings/errors are gone.
    Suggested fix: always post the Report messages context; use Result.Status.OK in the no-issues path.
Final Verdict

Status: ⚠️ Request changes
Minimum required actions:

  1. Remove legacy trusted labels from the untrusted PR runner fleet (or move trusted mac jobs to a separate trusted label/fleet).
  2. Define and implement the intended lifecycle for Report messages commit status; if reruns should clear failures, post explicit OK on clean reports.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 13, 2026
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch from 2a16e9b to da82ed0 Compare May 13, 2026 16:43
@maxknv maxknv changed the title CI: Prefix runs_on labels with pr- in PR workflow CI: Route PR workflow to isolated runner fleet via runs_on prefix May 13, 2026
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch from ac69ec8 to f141d84 Compare May 15, 2026 15:19
Comment thread ci/jobs/build_clickhouse.py Resolved
Comment thread ci/praktika/native_jobs.py Resolved
Comment thread ci/praktika/s3.py Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member

This was fixed by #105146. Let's update the branch.

maxknv added a commit that referenced this pull request May 18, 2026
Apply the same SCCACHE_S3_READ_ONLY guard to ci/jobs/fast_test.py that
build_clickhouse.py already has, so PR builds cannot pollute the shared
sccache bucket via the Fast test compile path.

Addresses #104870 (comment)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch 2 times, most recently from 48e91f3 to e487141 Compare May 18, 2026 14:45
maxknv added a commit that referenced this pull request May 19, 2026
Apply the same SCCACHE_S3_READ_ONLY guard to ci/jobs/fast_test.py that
build_clickhouse.py already has, so PR builds cannot pollute the shared
sccache bucket via the Fast test compile path.

Addresses #104870 (comment)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch from 5fb63c4 to 5bbfeae Compare May 19, 2026 15:32
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch from 5bbfeae to 86d7fb6 Compare May 19, 2026 21:58
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch from 86d7fb6 to ff7d42f Compare May 21, 2026 08:38
maxknv and others added 6 commits May 21, 2026 10:43
Walk every job in ci/workflows/pull_request.py and rewrite each runs_on
label with a pr- prefix, leaving self-hosted untouched. Jobs are
deep-copied via job.copy() before mutation so shared JobConfigs
instances used by other workflows are not affected.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Set SCCACHE_S3_READ_ONLY=true in build_clickhouse.py when
info.pr_number > 0 so PR builds do not write entries into the shared
sccache bucket; master/release builds (pr_number == 0) keep write
access.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add S3.assert_read_access that probes the cache bucket via head_object
and raises on anything other than 404/NoSuchKey/NotFound. Call it at the
top of the Cache Lookup block in native_jobs, so an AccessDenied from a
misconfigured runner fleet surfaces as an explicit failure instead of
masquerading as a workflow with zero cache hits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Apply the same SCCACHE_S3_READ_ONLY guard to ci/jobs/fast_test.py that
build_clickhouse.py already has, so PR builds cannot pollute the shared
sccache bucket via the Fast test compile path.

Addresses #104870 (comment)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`EC2Instance.Config`, `AutoScalingGroup.Config`, and `LaunchTemplate.Config`
now take `runner_labels: List[str]` instead of `runner_type: str`. The AWS
tag key `github:runner-type` is preserved (legacy `runner-init.py` in
clickhouse-private reads it and inlines its value verbatim into the GitHub
Actions runner's `--labels` list), so multiple comma-joined labels register
naturally as separate runner labels.

Switch macOS instances to the pre-existing `runner_oss_prs` instance
profile and drop the in-repo `praktika-ec2-instance-profile` definition.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`EC2Instance.deploy()` now reconciles state on already-running instances
instead of leaving it stale:

- `_sync_tags`: upserts the merged tag set and deletes any other
  non-`aws:*` tag found on the instances, so the config is the source
  of truth.
- `_sync_iam_instance_profile`: replaces / associates / disassociates
  the IAM instance profile to match the config. Skips instances that
  are not `running`/`pending` — `ReplaceIamInstanceProfileAssociation`
  fails with `IncorrectState` on stopped instances.
- `start_instances` failures (e.g. `InsufficientHostCapacity` on mac
  dedicated hosts) no longer abort the whole deploy: they're logged
  as warnings so subsequent instance configs are still processed.

Also defines `EC2_INSTANCE_PROFILE_NAME` in `ci/infra/cloud.py` and
points both mac configs at `runner_oss_prs`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch 2 times, most recently from 608edca to dbb635a Compare May 21, 2026 20:21
Comment thread ci/praktika/s3.py Resolved
@maxknv maxknv changed the title CI: Route PR workflow to isolated runner fleet via runs_on prefix CI: Redirect untrusted PR workflow to isolated CI env via runs_on prefixing May 22, 2026
@maxknv
maxknv marked this pull request as ready for review May 22, 2026 07:32
@maxknv maxknv changed the title CI: Redirect untrusted PR workflow to isolated CI env via runs_on prefixing CI: Route PR workflows to isolated runner fleet — zero-trust OSS CI, milestone 2 May 22, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@maxknv
maxknv force-pushed the ci-pr-runner-label-prefix branch from dbb635a to 12c0606 Compare May 22, 2026 11:09
…he hook

The `check_report_messages` post-hook now posts a GH commit status with a
short summary (e.g. `2 error(s), 1 warning(s)`) when the workflow report
contains errors or warnings, instead of exiting with a non-zero code.
The hook itself never fails, so it does not block the post-hook step
unnecessarily. A try/except guards against any unexpected errors.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
maxknv and others added 3 commits May 22, 2026 19:54
- `native_jobs.py`: gate `S3.assert_read_access` behind the same
  `skip_lookup` condition as actual remote cache lookup, so
  `Config Workflow` does not fail when cache is intentionally bypassed
  via `ci-force-all` label
- `s3.py`: wrap `head_object` in `_retry_on_no_credentials` so a
  transient IMDS credential miss does not permanently fail the probe
- `ec2_instance.py`: propagate `start_instances` failure instead of
  silently swallowing it; re-run IAM profile reconciliation on freshly
  started instances (previously skipped because `_sync_iam_instance_profile`
  ignores stopped instances)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… instances

`InsufficientHostCapacity` means no dedicated host is available — an
external capacity constraint we cannot fix programmatically. Treat it
as a warning and continue; re-raise all other `ClientError`s.

IAM profile re-reconciliation after start is now in the `else` branch
so it only runs when `start_instances` actually succeeds.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread ci/infra/cloud.py Resolved
@maxknv
maxknv enabled auto-merge May 23, 2026 08:11
@maxknv
maxknv disabled auto-merge May 23, 2026 10:11
@maxknv
maxknv enabled auto-merge May 23, 2026 10:11
@maxknv
maxknv disabled auto-merge May 23, 2026 10:12
@maxknv
maxknv added this pull request to the merge queue May 24, 2026
Merged via the queue into master with commit 82a745c May 24, 2026
167 of 168 checks passed
@maxknv
maxknv deleted the ci-pr-runner-label-prefix branch May 24, 2026 09:58
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 24, 2026
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
Apply the same SCCACHE_S3_READ_ONLY guard to ci/jobs/fast_test.py that
build_clickhouse.py already has, so PR builds cannot pollute the shared
sccache bucket via the Fast test compile path.

Addresses ClickHouse#104870 (comment)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
…el-prefix

CI: Route PR workflows to isolated runner fleet — zero-trust OSS CI, milestone 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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