From 4a595ccac10264cca34d08ce2db181033e60832b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 19 Nov 2026 06:46:44 +0000 Subject: [PATCH] fix(tests): attach the docker data-root loop with direct I/O MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docker_dataroot.sh attached the data-root image with plain 'losetup --find --show', so the loop worker wrote through the page cache of the backing file. Those dirty pages were charged to whichever container cgroup issued the writes; the swarm registry (mem_limit 512m) was OOM-killed during pushes, which failed with 'write: connection reset by peer' (IAM fork run 44423631737, n8n#0: 24 kills via loop_workfn -> lo_rw_aio -> ovl_write_iter, anon 15 MB vs file_dirty 470 MiB). Attaching with --direct-io=on bypasses that page cache. A backing filesystem without direct I/O makes the attach fail, and decline exits 1 for a stated filesystem, so the axis fails loudly instead of vanishing. Found and drafted by Stage 2.0; the unit test fails 3 subtests without the change and passes with it. 🎯 Fix: 85 % 💥 Break: 6 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 80 🚦 Gate: ⛔ fix 85 % < 90, break 6 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .../tests/deploy/utils/filesystem/docker_dataroot.sh | 2 +- .../deploy/utils/filesystem/test_docker_dataroot.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh b/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh index f3759350d4..19b45842ed 100755 --- a/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh +++ b/scripts/tests/deploy/utils/filesystem/docker_dataroot.sh @@ -281,7 +281,7 @@ while [ -z "${LOOP}" ] && [ "${attempt}" -lt 16 ]; do if [ -n "${candidate}" ] && [ ! -b "${candidate}" ]; then mknod "${candidate}" b 7 "${candidate#/dev/loop}" 2>/dev/null || candidate="" fi - if attached="$(losetup --find --show "${IMAGE}" 2>/dev/null)"; then + if attached="$(losetup --direct-io=on --find --show "${IMAGE}" 2>/dev/null)"; then LOOP="${attached}" fi done diff --git a/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py b/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py index 2a2aa707e4..154227d6c9 100644 --- a/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py +++ b/tests/unit/python/scripts/tests/deploy/utils/filesystem/test_docker_dataroot.py @@ -122,5 +122,17 @@ class TestDockerDatarootLoopMount(unittest.TestCase): self.assertIn(("-o", option), list(pairwise(mounts[0]))) +class TestDockerDatarootLoopAttach(unittest.TestCase): + def test_the_loop_bypasses_the_page_cache_of_its_backing_image(self) -> None: + for fstype in (*DISCARD, "zfs"): + with self.subTest(fstype=fstype): + _, calls = apply(fstype) + attaches = [ + argv for argv in calls if argv[0] == "losetup" and "--show" in argv + ] + self.assertEqual(len(attaches), 1, calls) + self.assertIn("--direct-io=on", attaches[0]) + + if __name__ == "__main__": unittest.main()