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
14 changes: 14 additions & 0 deletions .github/actions/truenas-appliance-runner/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ inputs:
data-disk-gb:
description: Size of each data disk.
default: '10'
extra-disk-gb:
description: >-
More sparse disks after the data disks, one per size in GB, separated
by spaces: '32' adds one 32 GB disk, '12 12 15' three. For what ten
alike cannot give, such as a disk big enough to mirror the boot pool
onto. Not for an HA pair.
default: ''
ssh:
description: '`true` enables ssh for the admin, on TN_SSH.'
default: 'false'
Expand Down Expand Up @@ -106,6 +113,7 @@ runs:
APPLIANCE_VCPUS: ${{ inputs.vcpus }}
APPLIANCE_DATA_DISKS: ${{ inputs.data-disk-count }}
APPLIANCE_DATA_DISK_GB: ${{ inputs.data-disk-gb }}
APPLIANCE_EXTRA_DISK_GB: ${{ inputs.extra-disk-gb }}
APPLIANCE_SSH: ${{ inputs.ssh }}
APPLIANCE_DISK_INPUT: ${{ inputs.disk }}
EXPORT_ENV: ${{ inputs.export-env }}
Expand All @@ -114,6 +122,12 @@ runs:
set -euo pipefail
lib="$GITHUB_ACTION_PATH"
[ -n "$APPLIANCE_DISK_INPUT" ] && export APPLIANCE_DISK="$APPLIANCE_DISK_INPUT"
# ha.sh would ignore it, and a suite would then skip whatever
# wanted the disks without saying why.
if [ "$HA" = true ] && [ -n "$APPLIANCE_EXTRA_DISK_GB" ]; then
echo "::error::extra-disk-gb is for one appliance; an HA pair has only the data-disk-count disks its nodes share"
exit 1
fi
export APPLIANCE_DIR="$RUNNER_TEMP/truenas-appliance"
# The password is made here, so it is masked before anything can
# print it.
Expand Down
24 changes: 23 additions & 1 deletion .github/actions/truenas-appliance-runner/appliance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
# (default $RUNNER_TEMP/truenas-appliance)
# APPLIANCE_MEMORY_MB 6144 APPLIANCE_VCPUS 4
# APPLIANCE_DATA_DISKS 10 APPLIANCE_DATA_DISK_GB 10 (sparse)
# APPLIANCE_EXTRA_DISK_GB more sparse disks after those, one per size in
# GB, space-separated: "32", "12 12 15" (default none)
# APPLIANCE_HTTP_PORT 8080 APPLIANCE_HTTPS_PORT 8443
# APPLIANCE_SSH_PORT 2222 APPLIANCE_SSH false
# APPLIANCE_BASELINE fresh-install: the snapshot start takes; empty
Expand Down Expand Up @@ -97,12 +99,18 @@ start() {
local disk="${APPLIANCE_DISK:-}"
local memory="${APPLIANCE_MEMORY_MB:-6144}" vcpus="${APPLIANCE_VCPUS:-4}"
local ndata="${APPLIANCE_DATA_DISKS:-10}" datagb="${APPLIANCE_DATA_DISK_GB:-10}"
local extragb=()
read -r -a extragb <<< "${APPLIANCE_EXTRA_DISK_GB:-}"
local http="${APPLIANCE_HTTP_PORT:-8080}" https="${APPLIANCE_HTTPS_PORT:-8443}" sshp="${APPLIANCE_SSH_PORT:-2222}"
local baseline="${APPLIANCE_BASELINE-fresh-install}"
local password="${APPLIANCE_PASSWORD:-$(head -c 15 /dev/urandom | base64 | tr -d '/+=')}"
local name="appliance-${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-1}-${GITHUB_JOB:-job}"

running && die "an appliance is running already ($DIR)"
local gb
for gb in "${extragb[@]}"; do
[[ "$gb" =~ ^[1-9][0-9]*$ ]] || die "APPLIANCE_EXTRA_DISK_GB: \"$gb\" is not a whole number of GB"
done
needs qemu-system-x86_64 qemu-system-x86 qemu-img qemu-utils python3 python3
ovmf
local accel="${APPLIANCE_ACCEL:-kvm}" cpu=host
Expand Down Expand Up @@ -135,9 +143,23 @@ start() {
drives+=(-drive "file=$DIR/data$i.qcow2,if=none,id=data$i,format=qcow2,discard=unmap"
-device "virtio-blk-pci,drive=data$i,serial=data$i")
done
# After the data disks, so a suite that takes the first unused disks
# still gets data disks, all of one size.
local nextra=0
for gb in "${extragb[@]}"; do
nextra=$((nextra + 1))
qemu-img create -q -f qcow2 "$DIR/extra$nextra.qcow2" "${gb}G"
drives+=(-drive "file=$DIR/extra$nextra.qcow2,if=none,id=extra$nextra,format=qcow2,discard=unmap"
-device "virtio-blk-pci,drive=extra$nextra,serial=extra$nextra")
done
local extrasaid=""
if [ "$nextra" -gt 0 ]; then
extrasaid=", and $nextra more of $(printf '%sG ' "${extragb[@]}")"
extrasaid="${extrasaid% }"
fi

local booted t0
say "booting $disk as $name: ${memory} MB, $vcpus vCPUs, $ndata data disks of ${datagb}G"
say "booting $disk as $name: ${memory} MB, $vcpus vCPUs, $ndata data disks of ${datagb}G$extrasaid"
t0=$(date +%s.%N)
qemu-system-x86_64 -name "$name" -machine "q35,accel=$accel" -cpu "$cpu" -smp "$vcpus" -m "$memory" \
-smbios "type=1,serial=$name" \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ jobs:
| `baseline` | `fresh-install` | Snapshot (`savevm`) taken once it is up; empty takes none |
| `memory-mb`, `vcpus` | `6144`, `4` | The appliance's; the runner's flavor needs room for it and the job |
| `data-disk-count`, `data-disk-gb` | `10`, `10` | Sparse qcow2 files |
| `extra-disk-gb` | none | More sparse disks after the data disks, one per size in GB: `'32'`, `'12 12 15'`. Not for an HA pair |
| `ssh` | `'false'` | `true` enables ssh for the admin, on `TN_SSH` |
| `disk` | the attached one | Found by its serial, `virtio-truenas_appliance`, where the box keeps it; TrueNAS replaces it, so otherwise the one disk besides the root disk that holds a ZFS `boot-pool` |
| `export-env` | `'true'` | Write `TN_*` to the job environment |
Expand Down
Loading