-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dhcp-proxy: apply new ip address/gateway
If we get a new lease with different ips or a new gateway we have to update the contianer netns with the new addresses. The added tests takes over 2m because the minimal lease time that dnsmasq supports is 2m so we have to love with that for now. One outstanding issue is that podman has no idea that things changed, it will continue to show incorrect network info in podman inspect. This never worked with CNI either so it should be ok for now. However I think it would be a great improvement for long running containers if we could somehow update the satus in podman. I think we need some hidden podman command callback where we can feed podman the new info. Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Showing
3 changed files
with
159 additions
and
15 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,59 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# Test that release is working after lease timeout | ||
# | ||
|
||
load helpers | ||
|
||
|
||
@test "release after timeout" { | ||
read -r -d '\0' input_config <<EOF | ||
{ | ||
"host_iface": "veth1", | ||
"container_iface": "veth0", | ||
"container_mac_addr": "$CONTAINER_MAC", | ||
"domain_name": "example.com", | ||
"host_name": "foobar", | ||
"version": 0, | ||
"ns_path": "$NS_PATH" | ||
} | ||
\0 | ||
EOF | ||
|
||
|
||
run_setup "$input_config" | ||
ip_before=$(jq -r '.yiaddr' <<<"$output") | ||
gw_before=$(jq -r '.gateways[0]' <<<"$output") | ||
has_ip "$ip_before" veth0 | ||
run_in_container_netns ip -j route show default | ||
assert "$output" =~ "$gw_before" | ||
|
||
|
||
# stop dhcp and restart with new subnet to get a new ip on the next lease | ||
stop_dhcp | ||
run_in_container_netns ip add del $(gateway_from_subnet) dev br0 | ||
run_in_container_netns ip addr | ||
run_in_container_netns ip route | ||
|
||
# get new subnet | ||
SUBNET_CIDR=$(random_subnet) | ||
run_in_container_netns ip addr add $(gateway_from_subnet) dev br0 | ||
stripped_subnet=$(strip_last_octet_from_subnet) | ||
run_dhcp | ||
|
||
run_in_container_netns ip addr | ||
run_in_container_netns ip route | ||
|
||
# Sigh, minimum lease time in dnsmasq is 2m, give some extra time for the | ||
# lease roundtrip and ip changes to be applied | ||
sleep 125 | ||
# after two minutes we should have a new lease and assigned the new ip | ||
has_ip "$stripped_subnet" veth0 | ||
|
||
# make sure we got the new gateway set as well | ||
run_in_container_netns ip -j route show default | ||
assert "$output" =~ "$(gateway_from_subnet)" | ||
|
||
# extra check to make sure we got our expected log | ||
run_helper grep "ip or gateway for mac $CONTAINER_MAC changed" "$TMP_TESTDIR/proxy.log" | ||
} |
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