Skip to content

Commit 4e45505

Browse files
committed
tests/containers: add a NFS server containers
This is prep work for enabling kdump over NFS testing. The previous attempt in #3911 used an image from openshift E2E tests, but I didn't pay attention to the image and the latest tag is not a multiarch manifest, so the pipeline tripped on that. Building the image ourselves will fix that.
1 parent ea1ad34 commit 4e45505

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

tests/containers/nfs/Containerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM registry.fedoraproject.org/fedora-minimal:41
2+
3+
RUN dnf -y install /usr/bin/ps nfs-utils && dnf clean all && rm -rf /var/cache/yum
4+
5+
ADD run_nfs.sh /usr/local/bin/
6+
7+
# expose mountd 20048/tcp and nfsd 2049/tcp
8+
EXPOSE 2049/tcp 20048/tcp
9+
10+
# Prepare mount point rw for everyone
11+
RUN mkdir /export && chmod 777 /export
12+
13+
# mark /export as a mount point
14+
VOLUME /export
15+
ENTRYPOINT ["/usr/local/bin/run_nfs.sh"]
16+
CMD ["/export"]

tests/containers/nfs/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# NFS Server Container
2+
3+
This is used by the `kdump.crash.nfs` test.
4+
5+
This image is forked from the [openshift e2e test image](https://github.com/openshift/kubernetes/tree/7ca9eb1e9e5ced974033c2b6f26560e22535244c/test/images/volume/nfs)
6+
7+
See https://github.com/coreos/coreos-assembler/pull/3911 for the inital PR using it for more details on the test.
8+
9+
It serves an empty `/` directory, writeable by anyone.
10+
Not for production use!

tests/containers/nfs/run_nfs.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
3+
set -uxo pipefail
4+
5+
function start()
6+
{
7+
8+
# prepare /etc/exports
9+
for i in "$@"; do
10+
# fsid=0: needed for NFSv4
11+
echo "$i *(rw,fsid=0,insecure,no_root_squash)" >> /etc/exports
12+
echo "Serving $i"
13+
done
14+
15+
# start rpcbind if it is not started yet
16+
/usr/sbin/rpcinfo 127.0.0.1 > /dev/null; s=$?
17+
if [ $s -ne 0 ]; then
18+
echo "Starting rpcbind"
19+
/usr/sbin/rpcbind -w
20+
fi
21+
22+
mount -t nfsd nfsd /proc/fs/nfsd
23+
24+
# -V 3: enable NFSv3
25+
/usr/sbin/rpc.mountd -N 2 -V 3
26+
27+
/usr/sbin/exportfs -r
28+
# -G 10 to reduce grace time to 10 seconds (the lowest allowed)
29+
/usr/sbin/rpc.nfsd -G 10 -V 3
30+
/usr/sbin/rpc.statd --no-notify
31+
echo "NFS started"
32+
}
33+
34+
function stop()
35+
{
36+
echo "Stopping NFS"
37+
38+
/usr/sbin/rpc.nfsd 0
39+
/usr/sbin/exportfs -au
40+
/usr/sbin/exportfs -f
41+
42+
kill "$( pidof rpc.mountd )"
43+
umount /proc/fs/nfsd
44+
echo > /etc/exports
45+
exit 0
46+
}
47+
48+
# rpc.statd has issues with very high ulimits
49+
ulimit -n 65535
50+
51+
trap stop TERM
52+
53+
start "$@"
54+
55+
set +x
56+
# Ugly hack to do nothing and wait for SIGTERM
57+
while true; do
58+
sleep 5
59+
done
60+

0 commit comments

Comments
 (0)