Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/scripts/test-native-queue-workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def test_dependabot_runs_the_same_trusted_pr_verifier(self):
job = verifier["jobs"]["verify"]
self.assertNotIn("if", job)
self.assertEqual(job["name"], "verify PR contents")
self.assertIn("docker run --rm", job["steps"][-1]["run"])
verify_step = next(step for step in job["steps"]
if step.get("name") == "Verifier action")
self.assertIn("docker run --rm", verify_step["run"])

def test_gosec_concurrency_fits_the_runner_cpu_limit(self):
# gosec defaults -concurrency to runtime.NumCPU(), which inside a
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/pr-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ permissions:
jobs:
verify:
name: verify PR contents
# Required on v5: keep on the self-hosted pool so a GitHub-hosted runner
# outage does not make otherwise-mergeable PRs impossible to merge.
# Fork PRs still fall back to GitHub-hosted for pull_request_target safety.
runs-on: ${{ (github.event_name != 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository) && fromJSON(vars.HIVE_RUNNER_LABELS || '["ubuntu-latest"]') || 'ubuntu-latest' }}
# This pinned v0.4.3 mirror is linux/arm64 only. Reuse the native ARM64
# override, never the general amd64 pool; forks stay on GitHub-hosted VMs.
runs-on: ${{ github.event.pull_request.head.repo.full_name == github.repository && fromJSON(vars.HIVE_ARM64_RUNNER || '["ubuntu-24.04-arm"]') || 'ubuntu-24.04-arm' }}
timeout-minutes: 10
env:
PR_VERIFIER_IMAGE: ghcr.io/hivecommons/pr-verifier@sha256:8c2b63817c4bfa7de510ab699b154637f27a42f87826c98083903daf2a539943
Expand All @@ -44,11 +43,21 @@ jobs:
- name: Pull verifier image
id: pull
continue-on-error: true
run: docker pull "$PR_VERIFIER_IMAGE"
run: |
if [ "$RUNNER_ARCH" != "ARM64" ]; then
echo "::error::The pinned PR Verifier requires native ARM64; HIVE_ARM64_RUNNER must not select $RUNNER_ARCH."
exit 1
fi
docker pull "$PR_VERIFIER_IMAGE"
image_platform="$(docker image inspect --format '{{.Os}}/{{.Architecture}}' "$PR_VERIFIER_IMAGE")"
if [ "$image_platform" != "linux/arm64" ]; then
echo "::error::PR Verifier platform $image_platform does not match the required linux/arm64."
exit 1
fi
- name: Report unreachable verifier image
if: steps.pull.outcome != 'success'
run: |
echo "::warning::PR Verifier image $PR_VERIFIER_IMAGE could not be pulled — verification was SKIPPED, not passed. This is a registry/image problem, not a PR problem (#6085)."
echo "::warning::PR Verifier image $PR_VERIFIER_IMAGE was unavailable or incompatible — verification was SKIPPED, not passed. Inspect the pull/platform error; this is a runner/registry/image problem, not a PR problem (#6085)."
- name: Verifier action
if: steps.pull.outcome == 'success'
id: verifier
Expand All @@ -67,3 +76,7 @@ jobs:
-v "$GITHUB_EVENT_PATH:/github/event.json:ro" \
-v "$GITHUB_WORKSPACE:/github/workspace:ro" \
"$PR_VERIFIER_IMAGE"
- name: Report verifier failure
if: steps.verifier.outcome == 'failure'
run: |
echo "::warning::PR Verifier returned a failure. This wrapper is advisory: inspect the individual PR checks and verifier log; a green wrapper does not prove those checks passed."
1 change: 1 addition & 0 deletions changelog.d/fixed-pr-verifier-native-arm64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Run the pinned ARM64-only PR verifier on native ARM64, preserve GitHub-hosted isolation for forks, and report incompatible or failed verification explicitly instead of leaving stale optional results unexplained.
62 changes: 61 additions & 1 deletion src/deploy/test_pr_verifier_advisory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fi
# not greps -- because `continue-on-error: true` and an `if:` expression are
# structure, and a substring check cannot tell which step owns them.
verdict="$(python3 - "$WORKFLOW" <<'PY'
import sys, yaml
import os, re, subprocess, sys, yaml

doc = yaml.safe_load(open(sys.argv[1]))
jobs = doc.get("jobs") or {}
Expand All @@ -85,6 +85,15 @@ for job_id, job in jobs.items():
verifier = verifier[0]
verifier_advisory = bool(verifier.get("continue-on-error"))

# Keep the known single-platform digest on a native runner, without
# letting an untrusted fork opt into the repository's self-hosted override.
selector = "${{ github.event.pull_request.head.repo.full_name == github.repository && fromJSON(vars.HIVE_ARM64_RUNNER || '[\"ubuntu-24.04-arm\"]') || 'ubuntu-24.04-arm' }}"
if re.sub(r"\s+", "", str(job.get("runs-on", ""))) != re.sub(r"\s+", "", selector):
problems.append(f"{job_id}: verifier must select native ARM64 and keep forks off the self-hosted override")
image = str((job.get("env") or {}).get("PR_VERIFIER_IMAGE", ""))
if not re.fullmatch(r"ghcr\.io/hivecommons/pr-verifier@sha256:[0-9a-f]{64}", image):
problems.append(f"{job_id}: verifier must retain an immutable canonical image digest")

# Registry-touching steps: the GHCR login, and the pull.
registry = find(lambda s:
"login" in str(s.get("name", "")).lower()
Expand Down Expand Up @@ -125,6 +134,57 @@ for job_id, job in jobs.items():
f"{job_id}: a skipped verification is silent -- no step warns when the image "
f"could not be pulled, so 'nothing ran' reads as 'it passed'")

# Exercise the actual pull/preflight script, with no registry or
# engine access. A bad override must stop before even pulling.
mock_docker = r'''
docker() {
if [ "$1" = "pull" ]; then
echo MOCK_PULL
return "$MOCK_PULL_EXIT"
elif [ "$1" = "image" ] && [ "$2" = "inspect" ]; then
printf '%s\n' "$MOCK_IMAGE_PLATFORM"
else
echo "unexpected docker command" >&2
return 90
fi
}
'''
cases = [
("ARM64", "linux/arm64", "0", True, True),
("X64", "linux/arm64", "0", False, False),
("ARM", "linux/arm64", "0", False, False),
("ARM64", "linux/amd64", "0", False, True),
("ARM64", "windows/arm64", "0", False, True),
("ARM64", "", "0", False, True),
("ARM64", "linux/arm64", "1", False, True),
]
for arch, platform, pull_exit, want_ok, want_pull in cases:
result = subprocess.run(
["bash", "-e", "-c", mock_docker + "\n" + str(pull[0].get("run", ""))],
env={
"PATH": os.environ.get("PATH", "/usr/bin:/bin"),
"RUNNER_ARCH": arch,
"PR_VERIFIER_IMAGE": image,
"MOCK_IMAGE_PLATFORM": platform,
"MOCK_PULL_EXIT": pull_exit,
},
capture_output=True, text=True, timeout=10,
)
if (result.returncode == 0) != want_ok or ("MOCK_PULL" in result.stdout) != want_pull:
problems.append(
f"{job_id}: platform preflight accepted/rejected the wrong case "
f"runner={arch}, image={platform!r}, pull_exit={pull_exit}: {result.stdout} {result.stderr}")
notes.append(f"{job_id}: native runner/image preflight exercised in {len(cases)} mocked cases")

failed_verifier_announced = [
s for s in steps
if "steps.verifier.outcome" in str(s.get("if", ""))
and "failure" in str(s.get("if", ""))
and "::warning" in str(s.get("run", ""))
]
if not failed_verifier_announced:
problems.append(f"{job_id}: a failed verifier must not silently look like successful verification")

for n in notes:
print("NOTE " + n)
for p in problems:
Expand Down
14 changes: 14 additions & 0 deletions src/docs/hivecommons-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ closing them.
[#5814](https://github.com/hivecommons/hive/issues/5814); PR content
verification must pull from the transferred `ghcr.io/hivecommons/pr-verifier`
package instead of the retired `ghcr.io/kubestellar/pr-verifier` reference.
The current immutable `v1` mirror contains only `linux/arm64`, not a
multi-architecture index. The Hive verifier therefore uses native ARM64:
same-repository PRs may use the existing `HIVE_ARM64_RUNNER` override, while
forks always use GitHub-hosted `ubuntu-24.04-arm`. No general runner-pool
variable is changed. The workflow checks both runner and image platform
before executing the verifier. Its upstream v0.4.3 source is
`kubernetes-sigs/kubebuilder-release-tools` commit
`012269a88fa4c034a0acf1ba84c26b195c0dbab4`; the image provenance names
`kubestellar/infra`, and `hivecommons/infra` carries the mirrored consumer.
A future multi-architecture replacement needs publication under
`ghcr.io/hivecommons/pr-verifier`, verification of its platform manifests
and source version, then a reviewed immutable-digest update in Hive's
`.github/workflows/pr-verifier.yml` and the infra reusable consumer.
Do not substitute an unverified tag or make forks use self-hosted runners.
6. **Hosted hub web domain** — In progress under
[#5951](https://github.com/hivecommons/hive/issues/5951); the canonical hub
is `https://hive.hivecommons.dev`, while `https://hive.kubestellar.io`
Expand Down
Loading