Skip to content

Commit 5733ce8

Browse files
committed
wip: nfs
1 parent 7070ad5 commit 5733ce8

File tree

6 files changed

+59
-50
lines changed

6 files changed

+59
-50
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -135,57 +135,9 @@ jobs:
135135
- cluster
136136
- standalone
137137
backend:
138-
- dir
139-
- btrfs
140-
- lvm
141-
- zfs
142-
- ceph
143-
- linstor
144-
- random
138+
- nfs
145139
os:
146140
- ubuntu-24.04
147-
include:
148-
- go: oldstable
149-
suite: cluster
150-
backend: dir
151-
os: ubuntu-24.04
152-
- go: oldstable
153-
suite: standalone
154-
backend: dir
155-
os: ubuntu-24.04
156-
- go: tip
157-
suite: cluster
158-
backend: dir
159-
os: ubuntu-24.04
160-
- go: tip
161-
suite: standalone
162-
backend: dir
163-
os: ubuntu-24.04
164-
165-
- go: oldstable
166-
suite: cluster
167-
backend: dir
168-
os: ubuntu-24.04-arm
169-
- go: oldstable
170-
suite: standalone
171-
backend: dir
172-
os: ubuntu-24.04-arm
173-
- go: stable
174-
suite: cluster
175-
backend: dir
176-
os: ubuntu-24.04-arm
177-
- go: stable
178-
suite: standalone
179-
backend: dir
180-
os: ubuntu-24.04-arm
181-
- go: tip
182-
suite: cluster
183-
backend: dir
184-
os: ubuntu-24.04-arm
185-
- go: tip
186-
suite: standalone
187-
backend: dir
188-
os: ubuntu-24.04-arm
189141
runs-on: ${{ matrix.os }}
190142

191143
steps:
@@ -434,6 +386,15 @@ jobs:
434386
# Update the runner env.
435387
echo "INCUS_LINSTOR_CLUSTER=${runner_ip}" >> "$GITHUB_ENV"
436388
389+
- name: Setup NFS
390+
if: ${{ matrix.backend == 'nfs' }}
391+
run: |
392+
set -x
393+
sudo apt-get install --no-install-recommends -y nfs-kernel-server
394+
echo "/media 10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash,no_all_squash)" | sudo tee /etc/exports
395+
sudo exportfs -a
396+
echo "INCUS_NFS_HOST=$(hostname -I | cut -d' ' -f1)" >> "$GITHUB_ENV"
397+
437398
- name: "Ensure offline mode (block image server)"
438399
run: |
439400
sudo nft add table inet filter
@@ -457,7 +418,7 @@ jobs:
457418
chmod +x ~
458419
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
459420
cd test
460-
sudo --preserve-env=PATH,GOPATH,GITHUB_ACTIONS,INCUS_VERBOSE,INCUS_BACKEND,INCUS_CEPH_CLUSTER,INCUS_CEPH_CEPHFS,INCUS_CEPH_CEPHOBJECT_RADOSGW,INCUS_LINSTOR_LOCAL_SATELLITE,INCUS_LINSTOR_CLUSTER,INCUS_OFFLINE,INCUS_SKIP_TESTS,INCUS_REQUIRED_TESTS, INCUS_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}
421+
sudo --preserve-env=PATH,GOPATH,GITHUB_ACTIONS,INCUS_VERBOSE,INCUS_BACKEND,INCUS_CEPH_CLUSTER,INCUS_CEPH_CEPHFS,INCUS_CEPH_CEPHOBJECT_RADOSGW,INCUS_LINSTOR_LOCAL_SATELLITE,INCUS_LINSTOR_CLUSTER,INCUS_NFS_HOST,INCUS_OFFLINE,INCUS_SKIP_TESTS,INCUS_REQUIRED_TESTS, INCUS_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}
461422
462423
client:
463424
name: Client

test/backends/nfs.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
nfs_setup() {
2+
# shellcheck disable=2039,3043
3+
local INCUS_DIR
4+
5+
INCUS_DIR=$1
6+
7+
echo "==> Setting up nfs backend in ${INCUS_DIR}"
8+
mkdir "/media/$(basename "$INCUS_DIR")"
9+
}
10+
11+
nfs_configure() {
12+
# shellcheck disable=2039,3043
13+
local INCUS_DIR
14+
15+
INCUS_DIR=$1
16+
17+
echo "==> Configuring nfs backend in ${INCUS_DIR}"
18+
19+
incus storage create "incustest-$(basename "${INCUS_DIR}")" nfs nfs.host="${INCUS_NFS_HOST}" "source=/media/$(basename "$INCUS_DIR")"
20+
incus profile device add default root disk path="/" pool="incustest-$(basename "${INCUS_DIR}")"
21+
}
22+
23+
nfs_teardown() {
24+
# shellcheck disable=2039,3043
25+
local INCUS_DIR
26+
27+
INCUS_DIR=$1
28+
29+
echo "==> Tearing down nfs backend in ${INCUS_DIR}"
30+
rm -rf "/media/$(basename "$INCUS_DIR")"
31+
}

test/includes/clustering.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ EOF
197197
config:
198198
source: incustest-$(basename "${TEST_DIR}" | sed 's/\./__/g')
199199
linstor.resource_group.place_count: 1
200+
EOF
201+
fi
202+
if [ "${driver}" = "nfs" ]; then
203+
cat >> "${INCUS_DIR}/preseed.yaml" << EOF
204+
config:
205+
nfs.host: $INCUS_NFS_HOST
206+
source: /media/$(basename "${TEST_DIR}")
200207
EOF
201208
fi
202209
cat >> "${INCUS_DIR}/preseed.yaml" << EOF

test/includes/incusd.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ spawn_incus() {
2727
elif [ "${INCUS_BACKEND}" = "linstor" ] && [ -z "${INCUS_LINSTOR_CLUSTER:-}" ]; then
2828
echo "A cluster name must be specified when using the LINSTOR driver." >&2
2929
exit 1
30+
elif [ "${INCUS_BACKEND}" = "nfs" ] && [ -z "${INCUS_NFS_HOST:-}" ]; then
31+
echo "A host name must be specified when using the NFS driver." >&2
32+
exit 1
3033
fi
3134

3235
# setup storage

test/includes/storage.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ available_storage_backends() {
4848
fi
4949
done
5050

51+
if [ -n "${INCUS_NFS_HOST:-}" ] && command -v "exportfs" > /dev/null 2>&1; then
52+
backends="$backends nfs"
53+
fi
54+
5155
if [ -n "${INCUS_TRUENAS_DATASET:-}" ] && command -v "truenas_incus_ctl" > /dev/null 2>&1; then
5256
backends="$backends truenas"
5357
fi

test/main.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ if [ "$INCUS_BACKEND" != "random" ] && ! storage_backend_available "$INCUS_BACKE
6363
elif [ "${INCUS_BACKEND}" = "truenas" ] && [ -z "${INCUS_TRUENAS_DATASET:-}" ]; then
6464
echo "TrueNAS storage backend requires that \"INCUS_TRUENAS_DATASET\" be set."
6565
exit 1
66+
elif [ "${INCUS_BACKEND}" = "nfs" ] && [ -z "${INCUS_NFS_HOST:-}" ]; then
67+
echo "LINSTOR storage backend requires that \"INCUS_NFS_HOST\" be set."
68+
exit 1
6669
fi
6770
echo "Storage backend \"$INCUS_BACKEND\" is not available"
6871
exit 1

0 commit comments

Comments
 (0)