fix(image): use compatible findmnt mount guard options
This commit is contained in:
+1
-1
@@ -60,7 +60,7 @@ sys.exit(code)
|
||||
|
||||
def rootfs_retry_guard_script():
|
||||
"""Refuse deletion of a still-mounted export, including nested mountpoints."""
|
||||
return r"""mounts=$(findmnt --list --raw --noheadings --output TARGET)
|
||||
return r"""mounts=$(findmnt --raw --noheadings --output TARGET)
|
||||
while IFS= read -r mountpoint; do
|
||||
case "$mountpoint" in
|
||||
"$root"|"$root/"*) echo 'Refusing to remove a mounted rootfs export' >&2; exit 1 ;;
|
||||
|
||||
@@ -128,6 +128,14 @@ class ImageTests(unittest.TestCase):
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(result.returncode == 0, not failed and not cleanup_failed)
|
||||
|
||||
def test_retry_guard_uses_valid_real_findmnt_options(self):
|
||||
from hydra.build import rootfs_retry_guard_script
|
||||
self.file('.hydra-export-owned')
|
||||
script = 'set -eu\nroot=' + shlex.quote(str(self.root)) + '\n' + rootfs_retry_guard_script()
|
||||
result = subprocess.run(['bash', '-c', script], capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertFalse(self.root.exists())
|
||||
|
||||
def test_retry_refuses_removing_owned_rootfs_with_stale_child_mount(self):
|
||||
from hydra.build import rootfs_retry_guard_script
|
||||
marker = self.file('.hydra-export-owned')
|
||||
|
||||
Reference in New Issue
Block a user