Skip to content
Closed
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
227 changes: 227 additions & 0 deletions .github/workflows/multiplane-acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
name: multiplane-acceptance
# The multi-plane acceptance in CI mode (docs/operations/multiplane.md#ci-mode)
# on a disposable GitHub-hosted runner: three kind clusters, Milo, Karmada, kro,
# Flux and a privileged libvirt/QEMU site Pod. Both modes run their guests
# under KVM. It runs on demand,
# nightly, and on a pull request only when the multiplane-acceptance label is
# applied, never on every push.
on:
workflow_dispatch:
inputs:
mode:
description: Site provider
type: choice
options: [both, localvm, redfish, media]
default: both
schedule:
- cron: '23 5 * * *'
pull_request:
types: [labeled]
permissions:
contents: read
jobs:
acceptance:
if: github.event_name != 'pull_request' || github.event.label.name == 'multiplane-acceptance'
name: acceptance (${{ matrix.mode }}, ${{ matrix.group }})
# Each suite runs as two shards on separate runners, after the same setup
# and core install scenarios: flux runs the Flux scenarios, release the
# reflection, release, reuse, deadline and rebuild scenarios. The
# acceptance job below passes only if every shard passed. A new suite is
# one more mode here and in the task selection below.
strategy:
fail-fast: false
matrix:
# Every suite but virtual media runs as its flux and release shards.
# The virtual media suite (run.sh --redfish --virtual-media) runs as
# one shard: its scenarios are one ordered sequence of installs.
include: ${{ fromJSON(github.event_name == 'workflow_dispatch' && inputs.mode == 'localvm' && '[{"mode":"localvm","group":"flux"},{"mode":"localvm","group":"release"}]' || github.event_name == 'workflow_dispatch' && inputs.mode == 'redfish' && '[{"mode":"redfish","group":"flux"},{"mode":"redfish","group":"release"}]' || github.event_name == 'workflow_dispatch' && inputs.mode == 'media' && '[{"mode":"media","group":"all"}]' || '[{"mode":"localvm","group":"flux"},{"mode":"localvm","group":"release"},{"mode":"redfish","group":"flux"},{"mode":"redfish","group":"release"},{"mode":"media","group":"all"}]') }}
# A newer labeled run for the same pull request replaces an older one;
# nightly and manual runs never cancel each other. A cancelled run never
# counts as passed.
concurrency:
group: multiplane-acceptance-${{ github.event.pull_request.number || github.run_id }}-${{ matrix.mode }}-${{ matrix.group }}
cancel-in-progress: true
runs-on: ubuntu-24.04
timeout-minutes: 120
env:
FLEET_MULTIPLANE_RUNTIME: ci
FLEET_MULTIPLANE_DOCKER_CONTEXT: default
FLEET_MULTIPLANE_ARCH: amd64
FLEET_MULTIPLANE_ACCEL: kvm
FLEET_MULTIPLANE_GROUP: ${{ matrix.group }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with: {persist-credentials: false}
# A pull request run tests GitHub's merge of the head into the base.
- name: Record the tested commits
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: printf 'Tested commit %s for head %s\n' "$(git rev-parse HEAD)" "$HEAD_SHA" | tee -a "$GITHUB_STEP_SUMMARY"
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with: {go-version-file: go.mod, cache: false}
# This job's own Go build cache: the readiness tests build with the race
# detector and the site binary without cgo, so a cache saved by another
# workflow holds neither. Keyed by commit, restoring the newest for the
# same go.sum.
# Saved after the build phase even when the run later fails, so a failing
# run still warms the next one.
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: multiplane-go-${{ matrix.mode }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }}
restore-keys: |
multiplane-go-${{ matrix.mode }}-${{ hashFiles('go.mod', 'go.sum') }}-
multiplane-go-${{ matrix.mode }}-
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with: {python-version: '3.12.12'}
- uses: imranismail/setup-kustomize@2ba527d4d055ab63514ba50a99456fc35684947f # v2
with: {kustomize-version: 5.8.1}
- name: Install pinned kind, kubectl and task
run: |
set -euo pipefail
go install sigs.k8s.io/kind@v0.31.0
go install github.com/go-task/task/v3/cmd/task@v3.53.1
directory=$(mktemp -d)
trap 'rm -rf "$directory"' EXIT
cd "$directory"
curl --fail --location --retry 3 --max-time 60 -o kubectl https://dl.k8s.io/release/v1.35.0/bin/linux/amd64/kubectl
curl --fail --location --retry 3 --max-time 60 -o kubectl.sha256 https://dl.k8s.io/release/v1.35.0/bin/linux/amd64/kubectl.sha256
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
mkdir -p "$HOME/.local/bin"
mv kubectl "$HOME/.local/bin/kubectl"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
# The runner's disk has far more free space than the 12 GiB the harness
# requires in the Docker data root, and preflight checks it.
- name: Record runner capacity
run: |
{
echo "FLEET_MULTIPLANE_STATE_ROOT=$RUNNER_TEMP/fleet-multiplane"
echo "METRICS=$RUNNER_TEMP/runner-metrics"
} >> "$GITHUB_ENV"
nproc
free -m
df -h / /var/lib/docker
docker version --format 'docker {{.Server.Version}}'
# Hosted runners restrict /dev/kvm to the kvm group; grant the runner
# access, as GitHub documents for hardware acceleration.
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls -l /dev/kvm || true
- name: Sample runner memory
run: |
mkdir -m 0700 "$METRICS"
# Every 10 s: memory, swap, the run's container memory and free disk. Container
# names and byte counts only. The script expands in its own shell.
# shellcheck disable=SC2016
nohup sh -c 'while :; do
printf "%s %s\n" "$(date -u +%FT%TZ)" "$(awk "/^(MemTotal|MemAvailable|SwapTotal|SwapFree):/ {printf \"%s=%s \", \$1, \$2}" /proc/meminfo)" >> "$1/meminfo.log"
docker stats --no-stream --format "{{.Name}} {{.MemUsage}}" 2>/dev/null | sed "s/^/$(date -u +%FT%TZ) /" >> "$1/containers.log"
printf "%s %s\n" "$(date -u +%FT%TZ)" "$(df -k --output=avail /var/lib/docker | tail -1)" >> "$1/disk.log"
sleep 10
done' sh "$METRICS" >/dev/null 2>&1 &
echo $! > "$METRICS/sampler.pid"
- name: Run multi-plane acceptance (${{ matrix.mode }})
timeout-minutes: 100
env:
TASK: ${{ matrix.mode == 'localvm' && 'multiplane:acceptance' || matrix.mode == 'media' && 'multiplane:media-acceptance' || 'multiplane:redfish-acceptance' }}
# The virtual media suite's lab windows, short enough for KVM guests:
# each held installation waits out both.
FLEET_MULTIPLANE_MEDIA_FETCH: ${{ matrix.mode == 'media' && '2m0s' || '' }}
FLEET_MULTIPLANE_MEDIA_REPORT: ${{ matrix.mode == 'media' && '3m0s' || '' }}
run: |
mkdir -m 0700 "$FLEET_MULTIPLANE_STATE_ROOT"
task "$TASK"
# A timeout or cancellation can stop run.sh before its own scan, so the
# evidence is scanned again here. A match is redacted in place, and the
# second scan must be clean before anything is uploaded.
- name: Record memory and secret-scan evidence
id: scan
if: always()
run: |
kill "$(cat "$METRICS/sampler.pid")" 2>/dev/null || true
sudo dmesg | grep -iE 'out of memory|oom-kill' > "$METRICS/oom.log" || true
python3 - "$METRICS" <<'PY' | tee "$METRICS/summary.txt" >> "$GITHUB_STEP_SUMMARY"
import pathlib, sys
m = pathlib.Path(sys.argv[1])
rows = [dict(f.split('=') for f in l.split()[1:]) for l in (m / 'meminfo.log').read_text().splitlines()] if (m / 'meminfo.log').exists() else []
if rows:
total = int(rows[0]['MemTotal:']) / 2**20
low = min(int(r['MemAvailable:']) for r in rows) / 2**20
swap = max(int(r['SwapTotal:']) - int(r['SwapFree:']) for r in rows) / 2**20
print('Runner memory: %.1f GiB total, %.1f GiB peak used, %.1f GiB minimum available, %.2f GiB peak swap, %d samples' % (total, total - low, low, swap, len(rows)))
disk = [int(l.split()[1]) for l in (m / 'disk.log').read_text().splitlines()] if (m / 'disk.log').exists() else []
if disk:
print('Runner disk: %.1f GiB minimum available in the Docker data root' % (min(disk) / 2**20))
oom = (m / 'oom.log').read_text().strip().splitlines() if (m / 'oom.log').exists() else []
print('Kernel OOM events: %d' % len(oom))
PY
found=false
for state in "$FLEET_MULTIPLANE_STATE_ROOT"/fleet-multiplane.*; do
[ -d "$state/evidence" ] || continue
mkdir -p "$state/evidence/runner"
cp "$METRICS"/meminfo.log "$METRICS"/containers.log "$METRICS"/summary.txt "$METRICS"/oom.log "$METRICS"/disk.log "$state/evidence/runner/" 2>/dev/null || true
if ! python3 hack/multiplane/harness.py scan --state "$state"; then
redacted=true
python3 hack/multiplane/harness.py scan --state "$state"
fi
found=true
done
echo "found=$found" >> "$GITHUB_OUTPUT"
echo "redacted=${redacted:-false}" >> "$GITHUB_OUTPUT"
# Both shards of a mode build the same binaries; one save per commit is
# enough, and a second save of the same key is skipped.
- name: Save the Go build cache
if: always() && matrix.group == 'release'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: multiplane-go-${{ matrix.mode }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }}
# Only evidence/ is uploaded, never the private state directory.
- name: Upload sanitized evidence
if: always() && steps.scan.outcome == 'success' && steps.scan.outputs.found == 'true'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: multiplane-evidence-${{ matrix.mode }}-${{ matrix.group }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/fleet-multiplane/fleet-multiplane.*/evidence/
if-no-files-found: error
retention-days: 14
# The job passes only if exactly one run recorded passed with every phase
# passed and teardown passed. A killed, timed-out or cancelled run fails.
- name: Verify the recorded result
if: always()
run: |
states=("$FLEET_MULTIPLANE_STATE_ROOT"/fleet-multiplane.*)
[ "${#states[@]}" -eq 1 ] && [ -d "${states[0]}" ] || { echo "expected exactly one run, found ${#states[@]}"; exit 1; }
python3 hack/multiplane/harness.py verify --state "${states[0]}" --group "$FLEET_MULTIPLANE_GROUP"
# A secret that reached evidence fails the job, even after its redaction.
- name: Fail on redacted evidence
if: always() && steps.scan.outputs.redacted == 'true'
run: |
echo 'evidence matched a retained secret and was redacted; see the scan step'
exit 1
# The one result for a run: it fails unless every shard of every suite
# passed, including when a shard was skipped or cancelled.
acceptance-result:
name: acceptance
if: always() && (github.event_name != 'pull_request' || github.event.label.name == 'multiplane-acceptance')
needs: acceptance
# A newer labeled run replaces this one too, so a replaced run leaves no
# stale result beside the new one.
concurrency:
group: multiplane-acceptance-${{ github.event.pull_request.number || github.run_id }}-result
cancel-in-progress: true
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Require every shard to pass
env:
RESULT: ${{ needs.acceptance.result }}
run: |
[ "$RESULT" = success ] || { echo "a multi-plane acceptance shard did not pass: $RESULT"; exit 1; }
echo 'every multi-plane acceptance shard passed'
3 changes: 2 additions & 1 deletion cmd/fleet-multiplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func run() error {
relays := fs.String("relays", "", "comma-separated prefixes of the report relays trusted to name a report's source (media-service)")
upstream := fs.String("upstream", "", "the media service's PROXY listener, IP:port (report-relay)")
clientCA := fs.String("client-ca", "", "CA that signs the site workers' client certificates (media-service)")
skewMargin := fs.Duration("skew-margin", 0, "replace the margin after a deadline before the coordinator declares it exceeded (coordinator)")
if err := fs.Parse(os.Args[2:]); err != nil {
return err
}
Expand All @@ -76,7 +77,7 @@ func run() error {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()
fmt.Println("coordinator: custody coordinator running")
return multiplane.Coordinate(ctx, config, *installationDeadline, func(err error) {
return multiplane.Coordinate(ctx, config, multiplane.CoordinatorOptions{InstallationDeadline: *installationDeadline, SkewMargin: *skewMargin}, func(err error) {
fmt.Fprintf(os.Stderr, "%s coordinator: pass incomplete: %v\n", time.Now().UTC().Format(time.RFC3339), err)
})
case "seed", "allocate", "install", "admit-install", "admit-install-b", "release", "release-b", "reuse", "recovery-mismatch", "probe-unallocatable", "tenant-isolation", "media-not-offered", "media-offered", "media-unpinned", "media-install-held", "media-install-download", "media-install-lost", "media-install":
Expand Down
24 changes: 19 additions & 5 deletions cmd/fleet-multiplane/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ func vmConfig() (vmwork.Config, fixture.Enrollment, error) {
default:
return vmwork.Config{}, nil, errors.New("FLEET_LOCAL_VM_ACCEL must be kvm or tcg")
}
if accelerator == "kvm" {
if _, err := os.Stat("/dev/kvm"); err != nil {
return vmwork.Config{}, nil, err
}
}
uri := os.Getenv("FLEET_LIBVIRT_URI")
if !strings.HasPrefix(uri, "qemu:///system?socket="+libvirtSocketDir+"/") {
return vmwork.Config{}, nil, errors.New("FLEET_LIBVIRT_URI must name the site's libvirt socket")
}
// The worker starts no hypervisor itself: the runtime behind the socket
// does, and it checks its own device. A worker runs only against a
// runtime that published the same accelerator.
if err := runtimeAccelerator(libvirtSocketDir, accelerator); err != nil {
return vmwork.Config{}, nil, err
}
var enrollment fixture.Enrollment
decoder := json.NewDecoder(strings.NewReader(os.Getenv("FLEET_SITE_ENROLLMENT")))
decoder.DisallowUnknownFields()
Expand All @@ -117,6 +118,19 @@ func vmConfig() (vmwork.Config, fixture.Enrollment, error) {
return config, enrollment, nil
}

// runtimeAccelerator checks that the VM runtime sharing dir published
// accelerator.
func runtimeAccelerator(dir, accelerator string) error {
data, err := os.ReadFile(filepath.Join(dir, "accelerator"))
if err != nil {
return errors.New("the site's VM runtime has not published its accelerator")
}
if published := strings.TrimSpace(string(data)); published != accelerator {
return fmt.Errorf("the site's VM runtime runs %s guests, not %s", published, accelerator)
}
return nil
}

// redfishBootServer is what the Redfish boot server needs: the artifacts it
// serves, the image they are, the listener firmware reaches, and where it
// records deliveries. It reads no enrollment or credential.
Expand Down
25 changes: 25 additions & 0 deletions cmd/fleet-multiplane/site_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"os"
"path/filepath"
"testing"
)

// TestAWorkerRunsOnlyAgainstARuntimeWithItsAccelerator refuses a runtime
// that published nothing or another accelerator.
func TestAWorkerRunsOnlyAgainstARuntimeWithItsAccelerator(t *testing.T) {
dir := t.TempDir()
if err := runtimeAccelerator(dir, "kvm"); err == nil {
t.Fatal("a runtime that published no accelerator was accepted")
}
if err := os.WriteFile(filepath.Join(dir, "accelerator"), []byte("tcg\n"), 0o600); err != nil {
t.Fatal(err)
}
if err := runtimeAccelerator(dir, "kvm"); err == nil {
t.Fatal("a KVM worker accepted a TCG runtime")
}
if err := runtimeAccelerator(dir, "tcg"); err != nil {
t.Fatalf("a TCG worker refused a TCG runtime: %v", err)
}
}
6 changes: 4 additions & 2 deletions config/multiplane/milo/base/milo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ spec:
enableServiceLinks: false
containers:
- name: apiserver
# Milo v0.32.5 (go.mod pin), native arm64 image.
image: ghcr.io/milo-os/milo@sha256:ec90618ecc723d6e175fbf49bc14292fd930be3e0251acb161c1166e6224279f
# Milo v0.32.5 (go.mod pin): the multi-arch index. It resolves to the arm64
# manifest sha256:ec90618e… on Colima and the amd64 manifest
# sha256:5db875d3… in CI mode.
image: ghcr.io/milo-os/milo@sha256:3b4f2890491220c4c79731d9e9b350881ce15dcca9de15b9f511cd7e5323f609
args:
- apiserver
- --etcd-servers=http://milo-etcd-0.milo-etcd:2379
Expand Down
5 changes: 4 additions & 1 deletion config/site/graph/rgd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ spec:
dispatch: boolean | default=false
# The central media service's certificate, for virtual media workers.
mediaCA: string | default=""
# The shared runtime's accelerator. Workers refuse a runtime that
# published another, and each installation's journal binds it.
accelerator: string | required=true
status:
bootOrigin: ${"http://" + bootService.spec.clusterIP + ":8080"}
workerImage: ${hypervisor.spec.template.spec.containers[0].image}
Expand Down Expand Up @@ -203,7 +206,7 @@ spec:
imagePullPolicy: IfNotPresent
command: [fleet-multiplane, site-worker, --handoff, "${handoff.metadata.name}", --cell, "${schema.spec.cell}"]
env:
- {name: FLEET_LOCAL_VM_ACCEL, value: tcg}
- {name: FLEET_LOCAL_VM_ACCEL, value: "${schema.spec.accelerator}"}
# The site's enrollment of the Devices it serves.
- name: FLEET_SITE_ENROLLMENT
valueFrom:
Expand Down
1 change: 1 addition & 0 deletions config/site/instance/dispatcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ spec:
# empty where no media service runs. It is public; workers verify the
# service with it.
mediaCA: "${FLEET_MEDIA_CA}"
accelerator: "${FLEET_LOCAL_VM_ACCEL}"
2 changes: 2 additions & 0 deletions config/site/redfish/services/bmc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ spec:
env:
- {name: FLEET_BOOT_IP, value: "${FLEET_BOOT_SERVICE_IP}"}
- {name: FLEET_LIBVIRT_URI, value: "qemu:///system?socket=/run/fleet-libvirt/libvirt-sock"}
# Lab targets run only while the site runtime publishes this accelerator.
- {name: FLEET_LAB_ACCEL, value: "${FLEET_LOCAL_VM_ACCEL}"}
- {name: HOME, value: /tmp}
ports:
- {name: redfish, containerPort: 8443}
Expand Down
2 changes: 1 addition & 1 deletion config/site/redfish/services/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ patches:
- name: report-relay
image: "${FLEET_SITE_IMAGE}"
imagePullPolicy: IfNotPresent
command: [fleet-multiplane, report-relay, --listen, "192.168.77.1:28443", --upstream, "192.168.5.2:28444"]
command: [fleet-multiplane, report-relay, --listen, "192.168.77.1:28443", --upstream, "${FLEET_MEDIA_HOST}:28444"]
securityContext:
runAsUser: 65534
runAsNonRoot: true
Expand Down
Loading
Loading