mirror of
https://github.com/containers/podman.git
synced 2025-11-01 22:32:50 +08:00
test/system: fix bridge host.containers.internal test
The test assumes that if more than 1 ip on the host we should be able to set host.containers.internal. This however is not how the logic works in the code. What it actually does is to check all ips in the rootless-netns and then it knows that it cannot use any of these ips. This includes any podman bridge ips. You can reproduce the error when you have only one ipv4 on the host then run a container as root in the background and run the test: hack/bats --rootless 505:host.containers.internal So the failure here was that there was already a podman container running as root on the default bridge thus the test saw 2 ips but then the rootless run also uses the same subnet for its bridge and the code knew that ip would not work either. I could have made another special condition in test but the better way to work around it is to create a new network. A new network will make sure there are no conflicting subnets assigned so the test will pass. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -802,7 +802,10 @@ EOF
|
||||
pasta_ip="$(default_addr 4)"
|
||||
host_ips=$(ip -4 -j addr | jq -r '.[] | select(.ifname != "lo") | .addr_info[].local')
|
||||
|
||||
for network in "pasta" "bridge"; do
|
||||
netname=n_$(safename)
|
||||
run_podman network create $netname
|
||||
|
||||
for network in "pasta" "$netname"; do
|
||||
# special exit code logic needed here, it is possible that there is no host.containers.internal
|
||||
# when there is only one ip one the host and that one is used by pasta.
|
||||
# As such we have to deal with both cases.
|
||||
@ -819,6 +822,8 @@ EOF
|
||||
fi
|
||||
done
|
||||
|
||||
run_podman network rm $netname
|
||||
|
||||
first_host_ip=$(head -n 1 <<<"$host_ips")
|
||||
run_podman run --rm --network=pasta:-a,169.254.0.2,-g,169.254.0.1,-n,24 $IMAGE grep host.containers.internal /etc/hosts
|
||||
assert "$output" =~ "^$first_host_ip" "uses host first ip"
|
||||
|
||||
Reference in New Issue
Block a user