Repository navigation
440 lines (396 loc) · 16.4 KB
/
Copy pathvm_test.yml
File metadata and controls
440 lines (396 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
name: custom VM spawner
on:
workflow_call:
inputs:
ref:
type: string
default: ''
# Optional overrides of the runners and of the versions below, e.g. from a
# manual dispatch. An empty value selects the default.
runners:
type: string
default: ''
runc_version:
type: string
default: ''
containerd_version:
type: string
default: ''
cni_version:
type: string
default: ''
nerdctl_version:
type: string
default: ''
crictl_version:
type: string
default: ''
firecracker_version:
type: string
default: ''
cloud_hypervisor_version:
type: string
default: ''
solo5_version:
type: string
default: ''
qemu_version:
type: string
default: ''
virtiofsd_version:
type: string
default: ''
hluk_version:
type: string
default: ''
permissions:
contents: read
# The default versions of the e2e environment are kept here, next to the steps
# that install them, and the callers only pass overrides. The monitors are the
# exception, as their defaults are in the find-monitors-release action. On
# pull_request events, the callers' inputs come from the PR merged into main,
# so they would not match a copy of this workflow loaded from another ref.
# Callers forward unset inputs as empty strings, which skip an input's default,
# hence the fallbacks.
env:
RUNC_VERSION: ${{ inputs.runc_version || '1.3.0' }}
CONTAINERD_VERSION: ${{ inputs.containerd_version || '2.3.7' }}
CNI_VERSION: ${{ inputs.cni_version || '1.7.1' }}
NERDCTL_VERSION: ${{ inputs.nerdctl_version || '2.1.3' }}
CRICTL_VERSION: ${{ inputs.crictl_version || 'v1.30.0' }}
jobs:
prepare:
name: VM test
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: ${{ fromJSON(inputs.runners || '["ubuntu-24.04", "ubuntu-24.04-arm"]') }}
test: ["test_ctr","test_nerdctl","test_crictl","test_docker"]
steps:
- name: Validate inputs (prevent command injection)
shell: bash
run: |
# The runner determines the architecture of the binaries and tests.
ARCH="$(dpkg --print-architecture)"
if [[ "$ARCH" != "amd64" && "$ARCH" != "arm64" ]]; then
echo "Unsupported architecture: $ARCH"
exit 1
fi
echo "ARCH=${ARCH}" >> "$GITHUB_ENV"
for var in RUNC_VERSION CONTAINERD_VERSION CNI_VERSION \
NERDCTL_VERSION CRICTL_VERSION; do
value="${!var}"
if ! [[ "$value" =~ ^v?[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "Invalid format for $var: $value"
exit 1
fi
done
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref }}
# On pull requests, the checkout above can be the base branch (see the
# vm_test job in ci.yml), while GitHub loaded this workflow from the merge
# commit (github.sha). Fetch the local actions from the latter, so that
# they match this workflow.
- name: Checkout the local actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
path: .workflow-actions
sparse-checkout: .github/actions/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Install base dependencies
run: |
sudo apt-get update
sudo apt-get install -y git wget build-essential bc make jq
- name: Install runc
run: |
SAFE_RUNC="${RUNC_VERSION}"
wget -q "https://github.com/opencontainers/runc/releases/download/v${SAFE_RUNC}/runc.$(dpkg --print-architecture)"
sudo install -m 755 runc.$(dpkg --print-architecture) /usr/local/sbin/runc
rm -f ./runc.$(dpkg --print-architecture)
- name: Install containerd
run: |
SAFE_CONTAINERD="${CONTAINERD_VERSION}"
wget -q "https://github.com/containerd/containerd/releases/download/v${SAFE_CONTAINERD}/containerd-${SAFE_CONTAINERD}-linux-$(dpkg --print-architecture).tar.gz"
sudo tar Cxzvf /usr/local "containerd-${SAFE_CONTAINERD}-linux-$(dpkg --print-architecture).tar.gz"
rm -f "containerd-${SAFE_CONTAINERD}-linux-$(dpkg --print-architecture).tar.gz"
- name: Set up containerd service
run: |
SAFE_CONTAINERD="$CONTAINERD_VERSION"
wget -q "https://raw.githubusercontent.com/containerd/containerd/v${SAFE_CONTAINERD}/containerd.service"
sudo rm -f /lib/systemd/system/containerd.service
sudo mv containerd.service /lib/systemd/system/containerd.service
sudo systemctl daemon-reload
sudo systemctl enable --now containerd
- name: Configure containerd
run: |
sudo mkdir -p /etc/containerd/
sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.bak || true
sudo containerd config default | sudo tee /etc/containerd/config.toml
sudo systemctl restart containerd
- name: Setup devmapper
run: |
sudo mkdir -p /usr/local/bin/scripts
sudo cp script/dm_create.sh /usr/local/bin/scripts/dm_create.sh
sudo chmod 755 /usr/local/bin/scripts/dm_create.sh
sudo /usr/local/bin/scripts/dm_create.sh
sudo sed -i "/\[plugins\.'io\.containerd\.snapshotter\.v1\.devmapper'\]/,/^$/d" /etc/containerd/config.toml
sudo tee -a /etc/containerd/config.toml > /dev/null <<'EOT'
[plugins.'io.containerd.snapshotter.v1.devmapper']
pool_name = "containerd-pool"
root_path = "/var/lib/containerd/io.containerd.snapshotter.v1.devmapper"
base_image_size = "10GB"
fs_type = "ext2"
EOT
sudo tee -a /etc/containerd/config.toml > /dev/null <<EOT
[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.urunc]
runtime_type = "io.containerd.urunc.v2"
container_annotations = ["com.urunc.unikernel.*"]
pod_annotations = ["com.urunc.unikernel.*"]
snapshotter = "devmapper"
EOT
# Since containerd 2.3, CRI pulls the images of a runtime into its
# snapshotter, so the transfer service must be able to unpack into
# devmapper. Setting unpack_config replaces the default overlayfs entry.
sudo tee -a /etc/containerd/config.toml > /dev/null <<EOT
[[plugins.'io.containerd.transfer.v1.local'.unpack_config]]
platform = "linux/$(dpkg --print-architecture)"
snapshotter = "overlayfs"
[[plugins.'io.containerd.transfer.v1.local'.unpack_config]]
platform = "linux/$(dpkg --print-architecture)"
snapshotter = "devmapper"
EOT
sudo systemctl restart containerd
- name: Setup block-based mountpoint
run: |
mkdir /tmp/test_mountpoint
dd if=/dev/zero of=/tmp/fake_block bs=1M count=200
mkfs.ext2 /tmp/fake_block
sudo mount /tmp/fake_block /tmp/test_mountpoint
- name: Install CNI plugins
run: |
SAFE_CNI="${CNI_VERSION}"
wget -q "https://github.com/containernetworking/plugins/releases/download/v${SAFE_CNI}/cni-plugins-linux-$(dpkg --print-architecture)-v${SAFE_CNI}.tgz"
sudo mkdir -p /opt/cni/bin
sudo tar Cxzvf /opt/cni/bin "cni-plugins-linux-$(dpkg --print-architecture)-v${SAFE_CNI}.tgz"
rm -f "cni-plugins-linux-$(dpkg --print-architecture)-v${SAFE_CNI}.tgz"
- name: Configure CNI network
run: |
sudo mkdir -p /etc/cni/net.d
sudo tee /etc/cni/net.d/10-containerd-net.conflist > /dev/null <<'EOT'
{
"cniVersion": "1.0.0",
"name": "containerd-net",
"plugins": [
{
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"hairpinMode": true,
"ipam": {
"type": "host-local",
"ranges": [
[{ "subnet": "10.88.0.0/16" }]
],
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
},
{
"type": "portmap",
"capabilities": { "portMappings": true }
},
{
"type": "firewall"
}
]
}
EOT
sudo systemctl restart containerd
- name: Install nerdctl
run: |
SAFE_NERDCTL="${NERDCTL_VERSION}"
wget -q "https://github.com/containerd/nerdctl/releases/download/v${SAFE_NERDCTL}/nerdctl-${SAFE_NERDCTL}-linux-$(dpkg --print-architecture).tar.gz"
sudo tar Cxzvf /usr/local/bin "nerdctl-${SAFE_NERDCTL}-linux-$(dpkg --print-architecture).tar.gz"
rm -f "nerdctl-${SAFE_NERDCTL}-linux-$(dpkg --print-architecture).tar.gz"
- name: Install crictl
run: |
SAFE_CRI="${CRICTL_VERSION}"
wget "https://github.com/kubernetes-sigs/cri-tools/releases/download/${SAFE_CRI}/crictl-${SAFE_CRI}-linux-${ARCH}.tar.gz"
sudo tar zxvf "crictl-${SAFE_CRI}-linux-${ARCH}.tar.gz" -C /usr/local/bin
rm -f "crictl-${SAFE_CRI}-linux-${ARCH}.tar.gz"
sudo tee -a /etc/crictl.yaml > /dev/null <<'EOT'
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 20
EOT
- name: Find the monitors-build release with these versions
id: monitors
uses: ./.workflow-actions/.github/actions/find-monitors-release
with:
firecracker_version: ${{ inputs.firecracker_version }}
cloud_hypervisor_version: ${{ inputs.cloud_hypervisor_version }}
hluk_version: ${{ inputs.hluk_version }}
solo5_version: ${{ inputs.solo5_version }}
qemu_version: ${{ inputs.qemu_version }}
virtiofsd_version: ${{ inputs.virtiofsd_version }}
arch: ${{ env.ARCH }}
- name: Install monitors
env:
MONITORS_URL: ${{ steps.monitors.outputs.url }}
MONITORS_SHA256: ${{ steps.monitors.outputs.sha256 }}
run: |
curl -fsSL -o monitors.tar.gz "${MONITORS_URL}"
echo "${MONITORS_SHA256} monitors.tar.gz" | sha256sum -c -
# The archive extracts to /opt/urunc, which is where the urunc
# configuration below points to. It records the files as owned by
# the user that built it, so let root own them instead.
sudo tar --no-same-owner --no-overwrite-dir -C /opt -xzf monitors.tar.gz
rm -f monitors.tar.gz
ls -l /opt/urunc/bin
- name: Install Firecracker for FreeBSD
env:
# FreeBSD needs Firecracker >= 1.12 and v1.7 required for Unikraft
# cannot boot it Installed under a dedicated name so the stock
# Firecracker above stays the default for every other runtime.
FC_FREEBSD_VERSION: v1.16.1
run: |
SAFE_FC="${FC_FREEBSD_VERSION}"
ARCH="$(uname -m)"
release_url="https://github.com/firecracker-microvm/firecracker/releases"
curl -L "${release_url}/download/${SAFE_FC}/firecracker-${SAFE_FC}-${ARCH}.tgz" | tar -xz
sudo mv "release-${SAFE_FC}-${ARCH}/firecracker-${SAFE_FC}-${ARCH}" /usr/local/bin/firecracker-freebsd
rm -fr "release-${SAFE_FC}-${ARCH}"
- name: Download urunc artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: urunc_static_${{ env.ARCH }}-${{ github.run_id }}
path: ./
- name: Download containerd-shim-urunc-v2 artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: containerd-shim-urunc-v2_static_${{ env.ARCH }}-${{ github.run_id }}
path: ./
- name: Install urunc
id: install-urunc
run: |
chmod +x urunc_static_${ARCH}
chmod +x containerd-shim-urunc-v2_static_${ARCH}
sudo mv urunc_static_${ARCH} /usr/local/bin/urunc
sudo mv containerd-shim-urunc-v2_static_${ARCH} /usr/local/bin/containerd-shim-urunc-v2
urunc --version
- name: Configure urunc with debug logging and the monitors' paths
run: |
sudo mkdir -p /etc/urunc
sudo tee /etc/urunc/config.toml > /dev/null <<EOF
[log]
level = "debug"
syslog = true
[monitors.qemu]
path = "/opt/urunc/bin/qemu-system-$(uname -m)"
data_path = "/opt/urunc/share/qemu"
[monitors.firecracker]
path = "/opt/urunc/bin/firecracker"
[monitors.cloud-hypervisor]
path = "/opt/urunc/bin/cloud-hypervisor"
[monitors.hyperlight-unikraft]
path = "/opt/urunc/bin/hluk"
[monitors.hvt]
path = "/opt/urunc/bin/solo5-hvt"
[monitors.spt]
path = "/opt/urunc/bin/solo5-spt"
[extra_binaries.virtiofsd]
path = "/opt/urunc/bin/virtiofsd"
EOF
- name: Configure FreeBSD urunc runtime (newer Firecracker)
run: |
# Dedicated urunc config that points at a different Firecracker binary
# for FreeBSD
sed 's|^path = "/opt/urunc/bin/firecracker"$|path = "/usr/local/bin/firecracker-freebsd"|' \
/etc/urunc/config.toml | sudo tee /etc/urunc/config-freebsd.toml > /dev/null
grep -q firecracker-freebsd /etc/urunc/config-freebsd.toml
sudo tee /usr/local/bin/containerd-shim-urunc-fc-v2 > /dev/null <<'EOF'
#!/bin/bash
URUNC_CONFIG_FILE=/etc/urunc/config-freebsd.toml exec /usr/local/bin/containerd-shim-urunc-v2 "$@"
EOF
sudo chmod +x /usr/local/bin/containerd-shim-urunc-fc-v2
- name: Allow unprivileged ICMP sockets
run: |
# The ping tests use unprivileged ICMP sockets, which Ubuntu 24.04
# does not allow by default (ping_group_range is "1 0").
sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
- name: Grant access to /dev/kvm
if: ${{ env.ARCH == 'amd64' }}
id: kvm-setup
run: |
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
- name: Prepare urunc folder
id: prepare
run: |
export GOROOT=$(go env GOROOT)
export PATH="$GOROOT/bin:$PATH"
go version
go env GOROOT
make prepare
- name: Wait for CRI network to be ready
run: |
for _ in $(seq 1 30); do
ready=$(sudo crictl info -o json 2>/dev/null | jq -r '.status.conditions[] | select(.type=="NetworkReady") | .status' || true)
if [ "$ready" = "true" ]; then
echo "CRI network is ready"
exit 0
fi
sleep 2
done
echo "CRI network did not become ready in time"
ls -l /etc/cni/net.d /opt/cni/bin || true
sudo crictl info || true
exit 1
- name: Run ${{ matrix.test }}
id: test
run: |
# Set up Go environment properly
export GOROOT=$(go env GOROOT)
export PATH="$GOROOT/bin:$PATH"
go version
go env GOROOT
if [ "${ARCH}" = "arm64" ]; then
sudo -E env "PATH=$PATH" "GOROOT=$GOROOT" make ${{ matrix.test }}_Spt
else
sudo -E env "PATH=$PATH" "GOROOT=$GOROOT" make ${{ matrix.test }}
fi
# Re-run the same suite with urunc's libcontainer runtime enabled,
# changing the configuration.
- name: Run ${{ matrix.test }} with libcontainer
id: test_libcontainer
run: |
sudo tee -a /etc/urunc/config.toml > /dev/null <<'EOF'
[runtime]
libcontainer = true
EOF
export GOROOT=$(go env GOROOT)
export PATH="$GOROOT/bin:$PATH"
if [ "${ARCH}" = "arm64" ]; then
sudo -E env "PATH=$PATH" "GOROOT=$GOROOT" make ${{ matrix.test }}_Spt
else
sudo -E env "PATH=$PATH" "GOROOT=$GOROOT" make ${{ matrix.test }} SKIP="Firecracker-unikraft-httpreply-static-net"
fi
- name: Dump urunc logs on failure
if: failure()
run: |
echo "=== urunc debug logs ==="
sudo journalctl --identifier=urunc --no-pager