From 593d0907c5c11e933be7dbdce98022f76183ea3c Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 9 Dec 2021 09:52:03 -0500 Subject: --hostname should be set when using --pod new:foobar Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2030599 When you create pod, it shares the UTS namespace with Containers. Currently the --hostname is not passed to the pod created when you create a container and pod in the same command. Also fix error message on supported --share flags Signed-off-by: Daniel J Walsh --- test/system/200-pod.bats | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index b166914db..57d052ce2 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -254,6 +254,8 @@ EOF run_podman run --rm --pod mypod $IMAGE hostname is "$output" "$hostname" "--hostname set the hostname" + run_podman 125 run --rm --pod mypod --hostname foobar $IMAGE hostname + is "$output" ".*invalid config provided: cannot set hostname when joining the pod UTS namespace: invalid configuration" "--hostname should not be allowed in share UTS pod" run_podman run --rm --pod $pod_id $IMAGE cat /etc/hosts is "$output" ".*$add_host_ip $add_host_n" "--add-host was added" @@ -337,4 +339,22 @@ EOF run_podman 1 image exists k8s.gcr.io/pause:3.5 } +@test "podman pod create --share" { + local pod_name="$(random_string 10 | tr A-Z a-z)" + run_podman 125 pod create --share bogus --name $pod_name + is "$output" ".*Invalid kernel namespace to share: bogus. Options are: cgroup, ipc, net, pid, uts or none" \ + "pod test for bogus --share option" + run_podman pod create --share cgroup,ipc --name $pod_name + run_podman run --rm --pod $pod_name --hostname foobar $IMAGE hostname + is "$output" "foobar" "--hostname should work with non share UTS namespace" +} + +@test "podman pod create --pod new:$POD --hostname" { + local pod_name="$(random_string 10 | tr A-Z a-z)" + run_podman run --rm --pod "new:$pod_name" --hostname foobar $IMAGE hostname + is "$output" "foobar" "--hostname should work when creating a new:pod" + run_podman pod rm $pod_name + run_podman run --rm --pod "new:$pod_name" $IMAGE hostname + is "$output" "$pod_name" "new:POD should have hostname name set to podname" +} # vim: filetype=sh -- cgit v1.2.3-54-g00ecf