imagecache: fall back to legacy mount on pre-6.5 kernels#504
Open
Mesut Oezdil (mesutoezdil) wants to merge 5 commits into
Open
imagecache: fall back to legacy mount on pre-6.5 kernels#504Mesut Oezdil (mesutoezdil) wants to merge 5 commits into
Mesut Oezdil (mesutoezdil) wants to merge 5 commits into
Conversation
The new mount API needs overlayfs lowerdir+, which only exists on Linux 6.5+. Probe it once at first mount and use plain mount(2) when missing, so older kernels do not fail every actor mount with EINVAL.
| // (Linux >= 6.5). The probe opens a throwaway fs context and tries the | ||
| // option against a directory that always exists; it never creates a | ||
| // superblock or touches the filesystem otherwise. | ||
| var lowerdirPlusSupported = sync.OnceValue(func() bool { |
Collaborator
There was a problem hiding this comment.
generally init() and friends are an anti-pattern especially interacting with the host from them ..., do we even need this probe versus just handling the error and falling back?
Contributor
Author
There was a problem hiding this comment.
thx for feedback, i removed the separate probe. now it just tries lowerdir+ on first layer directly, if kernel doesnt know it that call fails right away, then we fall back to legacy mount. No init() and no extra state.
added a test that forces this path with a fake option name so the fallback is actually covered now.
I think it’s better this way, it’s now responding to actual behaviour (rather than an assumption). PTAL
Drop the separate startup probe. mountOverlay now tries lowerdir+ on the first layer directly; if the kernel does not recognize it, that call fails immediately (before any path is touched), and we fall back to legacy mount(2) from there. Simpler and the fallback is now covered by a test that forces the failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #500.
SetupBundleRootfs mounts overlay rootfs with the new mount API,
using fsconfig lowerdir+ per layer. That option only exists on
Linux 6.5+. On older kernels every actor mount fails with a bare
EINVAL, which looks like flakiness, not a kernel version problem.
Fix: probe lowerdir+ support once (cheap fsopen/fsconfig dry run,
no real mount), log one clear line when missing, and fall back to
a plain mount(2) call built from the same lowerdir list. The legacy
path keeps the old ~34 layer cap and errors with a kernel hint if
the option string would go over the mount(2) page limit.
Tested with go test ./internal/imagecache/... on a real Linux
kernel (root, CAP_SYS_ADMIN, tmpfs upperdir), including a new test
that calls the legacy mount path directly and one for the option
string builder.