-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct output when inspecting containers created with --ipc #17201
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,20 @@ load helpers | |
|
||
@test "podman --ipc=host" { | ||
hostipc="$(readlink /proc/self/ns/ipc)" | ||
run_podman run --rm --ipc=host $IMAGE readlink /proc/self/ns/ipc | ||
run_podman run --name IPC --ipc=host $IMAGE readlink /proc/self/ns/ipc | ||
is "$output" "$hostipc" "HostIPC and container IPC should be same" | ||
run_podman inspect IPC --format '{{ .HostConfig.IpcMode }}' | ||
is "$output" "host" "host mode should be selected" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as a suggestion for future, not a blocker: I like my failure messages to make it clear why something is expected, not what is expected. (The "what" will be shown as part of the error message). Something like is "$output" "host" ".HostConfig.IpcMode when --ipc=host" That makes the error message something like:
|
||
run_podman rm IPC | ||
} | ||
|
||
@test "podman --ipc=none" { | ||
hostipc="$(readlink /proc/self/ns/ipc)" | ||
run_podman run --rm --ipc=none $IMAGE readlink /proc/self/ns/ipc | ||
run_podman run --ipc=none --name IPC $IMAGE readlink /proc/self/ns/ipc | ||
assert "$output" != "$hostipc" "containeripc should != hostipc" | ||
run_podman inspect IPC --format '{{ .HostConfig.IpcMode }}' | ||
is "$output" "none" "none mode should be selected" | ||
run_podman rm IPC | ||
|
||
run_podman 1 run --rm --ipc=none $IMAGE ls /dev/shm | ||
is "$output" "ls: /dev/shm: No such file or directory" "Should fail with missing /dev/shm" | ||
|
@@ -25,6 +31,8 @@ load helpers | |
hostipc="$(readlink /proc/self/ns/ipc)" | ||
run_podman run -d --ipc=private --name test $IMAGE sleep 100 | ||
assert "$output" != "$hostipc" "containeripc should != hostipc" | ||
run_podman inspect test --format '{{ .HostConfig.IpcMode }}' | ||
is "$output" "private" "private mode should be selected" | ||
|
||
run_podman 125 run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc | ||
is "$output" ".*is not allowed: non-shareable IPC (hint: use IpcMode:shareable for the donor container)" "Containers should not share private ipc namespace" | ||
|
@@ -36,6 +44,8 @@ load helpers | |
hostipc="$(readlink /proc/self/ns/ipc)" | ||
run_podman run -d --ipc=shareable --name test $IMAGE sleep 100 | ||
assert "$output" != "$hostipc" "containeripc(shareable) should != hostipc" | ||
run_podman inspect test --format '{{ .HostConfig.IpcMode }}' | ||
is "$output" "shareable" "shareable mode should be selected" | ||
|
||
run_podman run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc | ||
assert "$output" != "$hostipc" "containeripc(:test) should != hostipc" | ||
|
@@ -47,12 +57,19 @@ load helpers | |
@test "podman --ipc=container@test" { | ||
hostipc="$(readlink /proc/self/ns/ipc)" | ||
run_podman run -d --name test $IMAGE sleep 100 | ||
containerid=$output | ||
run_podman inspect test --format '{{ .HostConfig.IpcMode }}' | ||
is "$output" "shareable" "shareable mode should be selected" | ||
run_podman exec test readlink /proc/self/ns/ipc | ||
assert "$output" != "$hostipc" "containeripc(exec) should != hostipc" | ||
|
||
testipc=$output | ||
run_podman run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc | ||
run_podman run --name IPC --ipc=container:test $IMAGE readlink /proc/self/ns/ipc | ||
assert "$output" = "$testipc" "Containers should share ipc namespace" | ||
run_podman inspect IPC --format '{{ .HostConfig.IpcMode }}' | ||
is "$output" "container:$containerid" "ipc mode should be selected" | ||
run_podman rm IPC | ||
|
||
run_podman stop -t 0 test | ||
run_podman rm test | ||
} | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer a
switch
to theif/elses
in #17200, but I can't convince myself that this part of the change is equivalent. If adefault
case is possible, and none of the conditions trigger, won'tIpcMode
be left blank? (I don't know if this is possible)Moving line 186 (initialization to "host") to line 177 (before the switch) would ease my mind, but perhaps it's obvious to those familiar with this code why that is not necessary.