Test that remounting fixes 'stale file handle' errors.

This commit is contained in:
Ben Radford 2023-08-01 12:49:46 +01:00
parent 8225b7a011
commit 19164cf727
No known key found for this signature in database
GPG key ID: 9DF5D4640AB888D5
3 changed files with 54 additions and 1 deletions

View file

@ -8,6 +8,7 @@ overlay-local-store-tests := \
$(d)/delete-duplicate.sh \
$(d)/gc.sh \
$(d)/verify.sh \
$(d)/optimise.sh
$(d)/optimise.sh \
$(d)/stale-file-handle.sh
install-tests-groups += overlay-local-store

View file

@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -eu -o pipefail
set -x
source common.sh
# Avoid store dir being inside sandbox build-dir
unset NIX_STORE_DIR
unset NIX_STATE_DIR
storeDirs
initLowerStore
mountOverlayfs
buildInStore () {
nix-build --store "$1" ../hermetic.nix --arg busybox "$busybox" --arg seed 1 --no-out-link
}
triggerStaleFileHandle () {
# Arrange it so there are duplicate paths
nix-store --store "$storeA" --gc # Clear lower store
buildInStore "$storeB" # Build into upper layer first
buildInStore "$storeA" # Then build in lower store
# Duplicate paths mean GC will have to delete via upper layer
nix-store --store "$storeB" --gc
# Clear lower store again to force building in upper layer
nix-store --store "$storeA" --gc
# Now attempting to build in upper layer will fail
buildInStore "$storeB"
}
# Without remounting, we should encounter errors
expectStderr 1 triggerStaleFileHandle | grepQuiet 'Stale file handle'
# Configure remount-hook and reset OverlayFS
storeB="$storeB&remount-hook=$PWD/remount.sh"
remountOverlayfs
# Now it should succeed
triggerStaleFileHandle

View file

@ -0,0 +1,5 @@
source common.sh
requireEnvironment
setupConfig
execUnshare ./stale-file-handle-inner.sh