-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18344 from Luap99/container-ns
rootless: support joining containers that use host ns
- Loading branch information
Showing
2 changed files
with
90 additions
and
7 deletions.
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# Tests for the namespace options | ||
# | ||
|
||
load helpers | ||
|
||
@test "podman test all namespaces" { | ||
# format is nsname | option name | ||
tests=" | ||
cgroup | cgroupns | ||
ipc | ipc | ||
net | network | ||
pid | pid | ||
uts | uts | ||
" | ||
|
||
for nstype in private host; do | ||
while read name option; do | ||
local cname="c_${name}_$(random_string)" | ||
# ipc is special, private does not allow joining from another container. | ||
# Instead we must use "shareable". | ||
local type=$nstype | ||
if [ "$name" = "ipc" ] && [ "$type" = "private" ]; then | ||
type="shareable" | ||
fi | ||
|
||
run_podman run --name $cname --$option $type -d $IMAGE sh -c \ | ||
"readlink /proc/self/ns/$name; sleep inf" | ||
|
||
run_podman run --rm --$option container:$cname $IMAGE readlink /proc/self/ns/$name | ||
con2_ns="$output" | ||
|
||
run readlink /proc/self/ns/$name | ||
host_ns="$output" | ||
|
||
run_podman logs $cname | ||
con1_ns="$output" | ||
|
||
assert "$con1_ns" == "$con2_ns" "($name) namespace matches (type: $type)" | ||
local matcher="==" | ||
if [[ "$type" != "host" ]]; then | ||
matcher="!=" | ||
fi | ||
assert "$con1_ns" $matcher "$host_ns" "expected host namespace to ($matcher) (type: $type)" | ||
|
||
run_podman rm -f -t0 $cname | ||
done < <(parse_table "$tests") | ||
done | ||
} | ||
|
||
# vim: filetype=sh |