Files
computer-playbook/tests/unit/utils/storage/test_nfs.py
T
kevinveenbirkenbachandClaude Opus 4.8 9942dbdbcf fix(svc-storage-nfs-server): fsid=0 v4 root + nfs_* lookup SPOT
Root cause of the kernel-flavor swarm ENOENT: no export carried fsid=0, so the NFSv4 mount of the nested /srv/nfs/infinito-state sub-export had no pseudo-root anchor and the server returned NFS4ERR_NOENT on the PUTROOTFH+LOOKUP walk. crossmnt could not fix it (it only crosses a boundary mid-walk, never sets the starting filehandle). Kernel now exports the state dir itself at fsid=0 and clients mount the bare v4 root ':/' (zero LOOKUPs). ganesha keeps Pseudo=Path and v3 mounts the full path. The self-bind is kept so fsid=0 rides a real mount boundary (stable st_dev) under overlayfs DinD.

The NFS derivations move to per-value lookup plugins (nfs_flavor, nfs_client_src, nfs_fstype, nfs_mount_opts, nfs_state_path) backed by pure helpers in utils/storage/nfs.py with unit tests; group_vars STORAGE_NFS_* become thin lookup wrappers. The dev/act->ganesha flavor rule stays the single SPOT in the role config; nfs_flavor reads the merged value so client and server agree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 15:27:53 +02:00

47 lines
1.4 KiB
Python

import unittest
from utils.storage.nfs import client_src, fstype, mount_opts, state_path
class TestNfsHelpers(unittest.TestCase):
def test_state_path(self):
self.assertEqual(
state_path("/srv/nfs", "infinito-state"), "/srv/nfs/infinito-state"
)
def test_fstype(self):
self.assertEqual(fstype(4), "nfs4")
self.assertEqual(fstype("4"), "nfs4")
self.assertEqual(fstype(3), "nfs")
def test_mount_opts_dev_act_soft(self):
for rt in ("dev", "act"):
self.assertEqual(
mount_opts(4, rt), "vers=4,rw,soft,timeo=50,retrans=3,nolock"
)
def test_mount_opts_prod_hard(self):
for rt in ("github", "host"):
self.assertEqual(mount_opts(4, rt), "vers=4,rw,hard,timeo=600,nolock")
def test_client_src_kernel_v4_is_root(self):
self.assertEqual(
client_src("1.2.3.4", 4, "kernel", "/srv/nfs/infinito-state"), "1.2.3.4:/"
)
def test_client_src_ganesha_is_full_path(self):
self.assertEqual(
client_src("1.2.3.4", 4, "ganesha", "/srv/nfs/infinito-state"),
"1.2.3.4:/srv/nfs/infinito-state",
)
def test_client_src_v3_is_full_path(self):
self.assertEqual(
client_src("1.2.3.4", 3, "kernel", "/srv/nfs/infinito-state"),
"1.2.3.4:/srv/nfs/infinito-state",
)
if __name__ == "__main__":
unittest.main()