Skip to content

tests/slurm-epilog: check the cleanup status and add pathname regressions - #1410

Open
MaxFreedomPollard wants to merge 1 commit into
NVIDIA:masterfrom
MaxFreedomPollard:epilog-tests-mount-assertions
Open

MaxFreedomPollard wants to merge 1 commit into
NVIDIA:masterfrom
MaxFreedomPollard:epilog-tests-mount-assertions

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown

Fixes #1409. Test-only, no production code changes.

I saw in #1408 that this follow-up was offered to @100milliongold. If you already have it in progress, I am happy to close this one.

The three gaps from the issue:

  1. mount_case now checks the cleanup's exit status. An early exit leaves every payload in place, which is what the assertions look for, so it used to pass.
  2. The owned-mount-root case now also requires a sibling outside the mount to be removed, like the owned-parent and bind-mount cases. A surviving payload alone is also what a cleanup that never ran leaves behind.
  3. New pathname cases for [, backslash, *, ? and a trailing newline, each next to the sibling its mishandled name would match (data1 next to data[1], datax1 next to data*1). Each asserts both halves: the payload under the mount survives and the sibling is cleaned up. They script the mount table through an awk stub that prints the mount point in mountinfo's octal-escaped form, so they run without root. They are skipped when /proc/self/mountinfo is not readable, because the script checks for it before calling awk.

Testing

Run in an Ubuntu 24.04 container: 17 passed as an unprivileged user (mount-boundary cases skipped), 21 passed as root with --privileged. ShellCheck reports nothing before or after.

To check that the new assertions fail when they should, I ran the old and new harness against mutated copies of the template:

Mutant Old harness New harness
pattern=$mount_point, no escaping 16 passed [ and backslash fail (payload gone), * and ? fail (sibling spared)
mount_point=$(printf '%b' "$field") 16 passed the trailing-newline case fails (payload gone)
exit 17 after set -ex the owned-mount-root case passes all four mount cases fail with "the cleanup exited 17"
rm -fr replaced by : the owned-mount-root case passes the owned-mount-root case fails

Three test-only follow-ups from the review of NVIDIA#1408:

- mount_case discarded the cleanup's exit status. A cleanup that exits
  early leaves every payload in place, which is what the assertions
  look for, so it passed. The status is now part of the result.
- The owned-mount-root case only checked that the payload survived,
  which is also true of a cleanup that never ran. It now requires a
  sibling outside the mount to be removed as well.
- Nothing covered mount points that read as find -path patterns. Add
  cases for [, backslash, * and ?, and for a trailing newline, each
  next to the sibling its mishandled name would match. They script the
  mount table through an awk stub, so they run without root.

No production code changes.

Fixes NVIDIA#1409

Signed-off-by: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests/slurm-epilog: strengthen mount-boundary assertions and add pathname regressions

1 participant