Fix honoring tmpfs-size for user /dev/shm mount#35316
Conversation
|
could you add a test? |
What stops me is lack of |
dnephin
left a comment
There was a problem hiding this comment.
Would it be possible to test this with a unit test instead of an integration that? The fix seems to be in a single function, so having to make multiple API calls seems like it's maybe not the easiest way to reproduce and test the issue.
|
@AkihiroSuda @thaJeztah I have added the test case, and made sure it is failing without the fix (and passing with the fix applied). |
Problem is, there's a lot of code dealing with mounts, and the Anyway, let me give it a try and see what I end up with. |
Commit 7120976 ("Implement none, private, and shareable ipc modes") introduces a bug: if a user-specified mount for /dev/shm is provided, its size is overriden by value of ShmSize. A reproducer is simple: docker run --rm --mount type=tmpfs,dst=/dev/shm,tmpfs-size=100K \ alpine df /dev/shm This commit is an attempt to fix the bug, as well as optimize things a but and make the code easier to read. moby#35271 Signed-off-by: Kir Kolyshkin <[email protected]>
|
@dnephin OK, I managed to write a unit test. PTAL once time permits. |
There was a problem hiding this comment.
There was a problem hiding this comment.
I think this is one of the few times when a plain t.Fatal() is actually the best option:
t.Fatal("size option was missing from mount")There was a problem hiding this comment.
updated to use f.Fatal()
dnephin
left a comment
There was a problem hiding this comment.
Thanks, test LGTM, just one small nit
There was a problem hiding this comment.
I think this is one of the few times when a plain t.Fatal() is actually the best option:
t.Fatal("size option was missing from mount")|
Looks good, but haven't given it a spin yet; let me check if the |
|
@thaJeztah let us know :D |
|
Oh, looks like there's one linting failure: |
This test case is checking that the built-in default size for /dev/shm (which is used for `--ipcmode` being `private` or `shareable`) is not overriding the size of user-defined tmpfs mount for /dev/shm. In other words, this is a regression test case for issue moby#35271, moby#35271 Signed-off-by: Kir Kolyshkin <[email protected]>
- What I did
Commit 7120976 ("Implement none, private, and shareable ipc modes") introduces a bug: if a user-specified mount for /dev/shm is provided, its size is overridden by value of ShmSize. This was reported in #35271.
This commit is an attempt to fix this, as well as optimize things a but and make the code easier to read.
- How I did it
Appending the 'size' argument to /dev/shm mount options moved to an earlier place in the function, where we deal with the mounts that came from spec, therefore a user mount is left intact.
- How to verify it
There is a test case included in this PR. In addition, it can easily be checked manually:
Expected output (i.e. if there is no bug):
(i.e.
100should be shown under the "1K-blocks" header)- Description for the changelog
Fix honoring tmpfs-size for user /dev/shm mount
- A picture of a cute animal (not mandatory but encouraged)

Shy beaver | Minnesota zoo (source)