fix(ci): provider job에 sandbox runner 요구를 적고 시작 때 namespace를 점검한다
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Canceled after 0s
frontend-quality-gates / main / self-tests and removal drills (pull_request) Canceled after 0s
frontend-quality-gates / merge / static checks (pull_request) Canceled after 0s
frontend-quality-gates / merge / tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / browser tests (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Canceled after 0s
frontend-quality-gates / external-vulnerability-provider (pull_request) Canceled after 0s
frontend-quality-gates / external-provenance-provider (pull_request) Canceled after 0s
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Canceled after 0s
frontend-quality-gates / deploy-promoted-release (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Canceled after 0s
frontend-quality-gates / main / self-tests and removal drills (pull_request) Canceled after 0s
frontend-quality-gates / merge / static checks (pull_request) Canceled after 0s
frontend-quality-gates / merge / tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / browser tests (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Canceled after 0s
frontend-quality-gates / external-vulnerability-provider (pull_request) Canceled after 0s
frontend-quality-gates / external-provenance-provider (pull_request) Canceled after 0s
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Canceled after 0s
frontend-quality-gates / deploy-promoted-release (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Canceled after 0s
문제: release의 provider job 둘(vulnerability·provenance)은 FE-GATE-013과 같은 provider sandbox(systemd-run scope, bwrap --unshare-pid/ipc/uts/net)를 돈다. 그런데 생성 workflow의 runner 요구 주석은 게이트의 hostRequirements에서 나와 merge_test에만 붙고, provider job에는 없다. provider 감독 스크립트의 시작 점검도 실행 파일이 있는지만 봐서, 비특권 user namespace를 막는 runner에서는 나중에 bwrap 원문 오류로 끝난다. 고른 방법: - 계약 job에 선택 칸 `hostRequirements`를 두고 provider job 둘에 FE-GATE-013과 같은 요구를 적는다. 계약이 provider job의 요구가 FE-GATE-013과 같은지 보고(갈라지면 거절), provider 밖 job은 이 칸을 못 쓴다. 생성기가 그 job의 runs-on 옆에 주석을 쓴다. - `check-system-test-prerequisites.ts`에서 namespace 점검만 함수로 내보내고 (`findProviderSandboxNamespaceFailure`), `run-and-validate-provider.ts`가 provider를 띄우기 전에 부른다. 실패하면 test:system 사전 점검과 같은 문구(제한 이름, bwrap stderr, host 설정, 고치는 법)로 멈춘다. - 버린 대안: 생성기가 hostEnvironment 게이트의 요구를 provider job에 저절로 붙이기. 연결이 계약에 보이지 않는다. 위험·한계: provider job은 release 단계라 PR run에서 돌지 않는다. 새 점검은 desktop FE-GATE-013의 provider 시스템 시험(감독 스크립트를 실제로 띄움)으로 본다. 「provider 없이 배포할 때」 문서 절은 소유자 결정이라 이 커밋에 없다. 검증(desktop): 구현을 main으로 되돌리고 새 시험만 둔 상태에서 4개 실패 (RED), 고친 뒤 system-test-prerequisites·ci-workflow-generation 445개 통과, generate:ci-workflow·스냅샷 갱신, check:ci·check:types·eslint rc=0, verify:documentation PASS_SCOPED. desktop `scripts/verify.sh gate FE-GATE-013` rc=0 226초(시스템 컨테이너, system 시험 115개 통과 — provider 감독 스크립트를 실제로 띄워 새 점검을 거친다). 로그 /tmp/claude-gates/w2fe2-prov1/, w2fe2-prov013/. Refs: 1101/13-03
This commit is contained in:
@@ -82,7 +82,7 @@ jobs:
|
||||
name: "merge / tests"
|
||||
if: ${{ gitea.event_name != 'workflow_dispatch' || (inputs.stage != 'documentation' && inputs.stage != 'main') }}
|
||||
# FE-GATE-013 runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
@@ -303,6 +303,8 @@ jobs:
|
||||
vulnerability_provider:
|
||||
name: external-vulnerability-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
@@ -349,6 +351,8 @@ jobs:
|
||||
provenance_provider:
|
||||
name: external-provenance-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
|
||||
@@ -1807,7 +1807,7 @@
|
||||
"retentionClassId": "release-coherence",
|
||||
"hostRequirements": [
|
||||
"Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers",
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs"
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs"
|
||||
],
|
||||
"hostEnvironment": "system-container"
|
||||
},
|
||||
@@ -2506,6 +2506,10 @@
|
||||
"provider-evidence/vulnerability-report.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hostRequirements": [
|
||||
"Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers",
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2593,6 +2597,10 @@
|
||||
"provider-evidence/provenance-attestation.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
"hostRequirements": [
|
||||
"Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers",
|
||||
"unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -197,7 +197,11 @@ sandbox는 `bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net`으로
|
||||
이 옵션마다 비특권 user namespace가 필요하다. 이 조건은 provider job과 merge
|
||||
게이트 FE-GATE-013(`test:system`의 provider 테스트) 둘 다에 걸린다.
|
||||
`config/ci/gates.json`의 FE-GATE-013 `hostRequirements`에 같은 조건이 있고,
|
||||
생성 workflow는 그것을 merge job의 `runs-on` 옆 주석으로 보여 준다.
|
||||
생성 workflow는 그것을 merge job의 `runs-on` 옆 주석으로 보여 준다. release의
|
||||
provider job 둘도 같은 조건을 job의 `hostRequirements`로 갖고(계약이 FE-GATE-013과
|
||||
같은지 본다), 생성 workflow가 그 job의 `runs-on` 옆에 같은 주석을 쓴다.
|
||||
`scripts/run-and-validate-provider.ts`는 provider를 띄우기 전에 아래 검사와 같은
|
||||
namespace 점검을 돌아, 이 조건이 없는 runner에서 이름과 host 설정을 대며 멈춘다.
|
||||
|
||||
- Ubuntu 23.10부터는 `kernel.apparmor_restrict_unprivileged_userns=1`이
|
||||
기본이다(24.04도 같다). `/usr/bin/bwrap`에 `userns`를 허용하는 AppArmor
|
||||
|
||||
@@ -88,14 +88,24 @@ export async function findSystemTestPrerequisiteFailures(
|
||||
}
|
||||
|
||||
if (executable.get(BWRAP)) {
|
||||
const probe = host.spawn(BWRAP, NAMESPACE_PROBE_ARGUMENTS, PROBE_TIMEOUT_MS);
|
||||
if (probe.error || probe.status !== 0) {
|
||||
failures.push(await namespaceFailure(host, probe));
|
||||
}
|
||||
const failure = await findProviderSandboxNamespaceFailure(host);
|
||||
if (failure !== undefined) failures.push(failure);
|
||||
}
|
||||
return failures;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1101/13-03. Whether this host lets the provider sandbox create its
|
||||
* namespaces, and if not, why and what to do. The release provider jobs run
|
||||
* it before the provider (scripts/run-and-validate-provider.ts).
|
||||
*/
|
||||
export async function findProviderSandboxNamespaceFailure(
|
||||
host: SystemTestHost = nodeSystemTestHost,
|
||||
): Promise<string | undefined> {
|
||||
const probe = host.spawn(BWRAP, NAMESPACE_PROBE_ARGUMENTS, PROBE_TIMEOUT_MS);
|
||||
return probe.error || probe.status !== 0 ? namespaceFailure(host, probe) : undefined;
|
||||
}
|
||||
|
||||
async function namespaceFailure(
|
||||
host: SystemTestHost,
|
||||
probe: ReturnType<SystemTestHost["spawn"]>,
|
||||
|
||||
@@ -432,6 +432,9 @@ const jobSchema = z
|
||||
browserGateIds: z.array(id).max(64),
|
||||
environment: z.array(environmentBindingSchema).max(32),
|
||||
steps: z.array(jobStepSchema).min(1).max(64),
|
||||
// 1101/13-03. What the runner of a job without a gate needs (the provider
|
||||
// jobs' sandbox). Rendered beside its runner label like a gate's.
|
||||
hostRequirements: z.array(nonEmpty.max(512)).min(1).max(8).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
@@ -862,6 +865,20 @@ function validateContractSemantics(
|
||||
// paired backend's nightly lanes.
|
||||
main_gate: ["FE-GATE-029", "FE-GATE-030"],
|
||||
};
|
||||
// 1101/13-03. The provider jobs run FE-GATE-013's sandbox (systemd-run
|
||||
// scope, bwrap with the same namespace options), so they need its host.
|
||||
const sandboxRequirements = JSON.stringify(
|
||||
contract.gates.find(({ id: gateId }) => gateId === "FE-GATE-013")?.hostRequirements ?? [],
|
||||
);
|
||||
for (const job of contract.jobs) {
|
||||
if (job.kind === "provider") {
|
||||
if (JSON.stringify(job.hostRequirements ?? []) !== sandboxRequirements) {
|
||||
issue(`provider job host requirements must equal FE-GATE-013's: ${job.id}`);
|
||||
}
|
||||
} else if (job.hostRequirements !== undefined) {
|
||||
issue(`only a provider job declares host requirements of its own: ${job.id}`);
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(contract.jobs.map(({ id }) => id)) !== JSON.stringify(Object.keys(expectedJobOwnership))) {
|
||||
issue("job registry must contain the exact thirteen canonical jobs in semantic order");
|
||||
}
|
||||
|
||||
@@ -267,11 +267,17 @@ function renderHostRequirements(
|
||||
job: CiWorkflowJob,
|
||||
index: ReturnType<typeof indexCiGateContract>,
|
||||
): string[] {
|
||||
return job.gateIds.flatMap((gateId) =>
|
||||
(index.gates.get(gateId)?.hostRequirements ?? []).map(
|
||||
(requirement) => ` # ${gateId} runner requirement: ${requirement}`,
|
||||
return [
|
||||
...job.gateIds.flatMap((gateId) =>
|
||||
(index.gates.get(gateId)?.hostRequirements ?? []).map(
|
||||
(requirement) => ` # ${gateId} runner requirement: ${requirement}`,
|
||||
),
|
||||
),
|
||||
);
|
||||
// 1101/13-03. A provider job runs the provider sandbox and has no gate.
|
||||
...(job.hostRequirements ?? []).map(
|
||||
(requirement) => ` # provider sandbox runner requirement: ${requirement}`,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
type ProviderGuardianLease,
|
||||
} from "./lib/provider-guardian-client.ts";
|
||||
import { createProviderOutputLimiter } from "./lib/provider-output-limiter.ts";
|
||||
import { findProviderSandboxNamespaceFailure } from "./check-system-test-prerequisites.ts";
|
||||
import { PROVIDER_SANDBOX_NAMESPACE_ARGUMENTS } from "./lib/provider-sandbox-namespaces.ts";
|
||||
import {
|
||||
providerProcessTraceEnvironment,
|
||||
@@ -125,6 +126,13 @@ await access("/usr/bin/systemd-run", constants.X_OK).catch(() => {
|
||||
await access("/usr/bin/systemctl", constants.X_OK).catch(() => {
|
||||
throw new Error("provider cgroup unavailable: /usr/bin/systemctl is required");
|
||||
});
|
||||
// 1101/13-03. A runner that refuses the sandbox's unprivileged user and
|
||||
// network namespaces fails here, by name and with its host settings, instead
|
||||
// of later with bwrap's raw error.
|
||||
const namespaceFailure = await findProviderSandboxNamespaceFailure();
|
||||
if (namespaceFailure !== undefined) {
|
||||
throw new Error(`provider sandbox unavailable: ${namespaceFailure}`);
|
||||
}
|
||||
await assertProviderCgroupManagerAvailable();
|
||||
const trust = await readProviderTrust(workspaceRoot, publicKeyPath, keyId);
|
||||
if (!trust) throw new TypeError("provider supervisor trust key is invalid");
|
||||
|
||||
@@ -85,7 +85,7 @@ jobs:
|
||||
name: "merge / tests"
|
||||
if: \${{ gitea.event_name != 'workflow_dispatch' || (inputs.stage != 'documentation' && inputs.stage != 'main') }}
|
||||
# FE-GATE-013 runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs
|
||||
# FE-GATE-013 runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
@@ -306,6 +306,8 @@ jobs:
|
||||
vulnerability_provider:
|
||||
name: external-vulnerability-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
@@ -352,6 +354,8 @@ jobs:
|
||||
provenance_provider:
|
||||
name: external-provenance-provider
|
||||
needs: immutable_build
|
||||
# provider sandbox runner requirement: Linux with executable /usr/bin/bwrap (with --size), /usr/bin/prlimit, /usr/bin/systemd-run, /usr/bin/systemctl and /usr/bin/tar, an active systemd user manager 254 or newer, and unified cgroup v2 with delegated memory, pids and cpu controllers
|
||||
# provider sandbox runner requirement: unprivileged user and network namespaces for bwrap (the provider sandbox runs bwrap --unshare-pid --unshare-ipc --unshare-uts --unshare-net); Ubuntu 23.10 and later refuse them while kernel.apparmor_restrict_unprivileged_userns=1 unless /usr/bin/bwrap has an AppArmor profile that allows userns; scripts/check-system-test-prerequisites.ts probes this before test:system runs and scripts/run-and-validate-provider.ts before a provider runs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
outputs:
|
||||
|
||||
@@ -1724,7 +1724,44 @@ describe("CI workflow generation", () => {
|
||||
expect(header.split("\n").filter((line) => line.startsWith(" # "))).toEqual(
|
||||
requirements.map((requirement) => ` # FE-GATE-013 runner requirement: ${requirement}`),
|
||||
);
|
||||
expect(workflow.match(/ runner requirement: /gu)).toHaveLength(requirements.length);
|
||||
// FE-GATE-013 in merge_test, and the two release provider jobs.
|
||||
expect(workflow.match(/ runner requirement: /gu)).toHaveLength(requirements.length * 3);
|
||||
});
|
||||
|
||||
// 1101/13-03. The release provider jobs run the same sandbox (systemd-run
|
||||
// scope, bwrap with the same namespace options) on whatever runner picks
|
||||
// them up, and nothing beside their runner label said what it needs.
|
||||
it("states the provider sandbox's runner requirements beside each provider job's runner label", async () => {
|
||||
const contract = await loadCiGateContract(process.cwd());
|
||||
const index = indexCiGateContract(contract);
|
||||
const requirements = index.gates.get("FE-GATE-013")?.hostRequirements ?? [];
|
||||
expect(requirements.length).toBeGreaterThan(0);
|
||||
const providerJobs = contract.jobs.filter(({ kind }) => kind === "provider");
|
||||
expect(providerJobs.map(({ id }) => id)).toEqual(["vulnerability_provider", "provenance_provider"]);
|
||||
for (const job of providerJobs) expect(job.hostRequirements).toEqual(requirements);
|
||||
|
||||
const workflow = renderCiWorkflow(contract);
|
||||
for (const [job, next] of [
|
||||
["vulnerability_provider", "provenance_provider"],
|
||||
["provenance_provider", "promotion"],
|
||||
] as const) {
|
||||
const block = workflow.slice(workflow.indexOf(` ${job}:\n`), workflow.indexOf(` ${next}:\n`));
|
||||
const header = block.slice(0, block.indexOf(" runs-on: ubuntu-latest\n"));
|
||||
expect(header.split("\n").filter((line) => line.startsWith(" # ")), job).toEqual(
|
||||
requirements.map((requirement) => ` # provider sandbox runner requirement: ${requirement}`),
|
||||
);
|
||||
}
|
||||
|
||||
// A provider job's requirements are the sandbox's: they cannot drift from FE-GATE-013's.
|
||||
const drifted = {
|
||||
...contract,
|
||||
jobs: contract.jobs.map((job) =>
|
||||
job.id === "provenance_provider" ? { ...job, hostRequirements: ["a different runner"] } : job,
|
||||
),
|
||||
};
|
||||
expect(() => parseCiGateContract(drifted)).toThrow(
|
||||
/provider job host requirements must equal FE-GATE-013's: provenance_provider/u,
|
||||
);
|
||||
});
|
||||
|
||||
// The job container has neither systemd nor bubblewrap, so FE-GATE-013 runs
|
||||
|
||||
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
findProviderSandboxNamespaceFailure,
|
||||
findSystemTestPrerequisiteFailures,
|
||||
formatSystemTestPrerequisiteReport,
|
||||
NAMESPACE_PROBE_ARGUMENTS,
|
||||
@@ -123,3 +124,35 @@ describe("system test prerequisites (1105/12-01)", () => {
|
||||
expect(calls.map(({ command }) => command)).toEqual(["/usr/bin/systemctl"]);
|
||||
});
|
||||
});
|
||||
|
||||
// 1101/13-03. The release provider jobs run the same sandbox on whatever
|
||||
// runner picks them up. The supervisor checked only that the executables
|
||||
// exist, so a host that refuses the namespaces failed later with bwrap's raw
|
||||
// error and without the host settings.
|
||||
describe("provider sandbox namespace check (1101/13-03)", () => {
|
||||
it("passes on a host that creates the namespaces and probes only with bwrap", async () => {
|
||||
const { host, calls } = fakeHost({ status: 0, stderr: "" });
|
||||
|
||||
expect(await findProviderSandboxNamespaceFailure(host)).toBeUndefined();
|
||||
expect(calls).toEqual([{ command: "/usr/bin/bwrap", args: NAMESPACE_PROBE_ARGUMENTS }]);
|
||||
});
|
||||
|
||||
it("names the restriction, bwrap's stderr and the host settings on a host that refuses them", async () => {
|
||||
const { host } = fakeHost(
|
||||
{ status: 1, stderr: `${RTM_NEWADDR}\n` },
|
||||
{ "/proc/sys/kernel/apparmor_restrict_unprivileged_userns": "1\n" },
|
||||
);
|
||||
|
||||
const failure = (await findProviderSandboxNamespaceFailure(host)) ?? "";
|
||||
expect(failure).toMatch(/^this host does not allow unprivileged user and network namespaces/u);
|
||||
expect(failure).toContain(`bwrap stderr: ${RTM_NEWADDR}`);
|
||||
expect(failure).toContain("kernel.apparmor_restrict_unprivileged_userns = 1");
|
||||
});
|
||||
|
||||
it("runs before the provider supervisor launches anything", async () => {
|
||||
const provider = await readFile("scripts/run-and-validate-provider.ts", "utf8");
|
||||
const check = provider.indexOf("await findProviderSandboxNamespaceFailure()");
|
||||
expect(check).toBeGreaterThan(0);
|
||||
expect(check).toBeLessThan(provider.indexOf("superviseProviderEvidence({"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user