-
Notifications
You must be signed in to change notification settings - Fork 85
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
Add container hostname to DHCP requests and use container id as client id #1130
base: main
Are you sure you want to change the base?
Conversation
With this PR, netvark will still build and run fine with older containers/common code that doesn't set the container_hostname. It just won't send a hostname in the DHCP request. |
5094f03
to
17f64da
Compare
Sure, LGTM |
db2be94
to
8eb5569
Compare
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.
Also we should have a test for it. Currently we only have some basic dhcp tests in test-dhcp/ but we need to cover both case at least (with and without hostname)
The basic setup
test sets "host_name": "foobar"
so we should verify the hostname was passed. We should be able to read the dnsmasq log assuming it logs the hostname.
But then we also should have a second case with an empty hostname so we know we keep no hostname working as well.
8eb5569
to
8706001
Compare
I'm marking this as draft until I can think of a better way to handle client id. |
8706001
to
bbc316c
Compare
HA! I just discovered a bug in mozim. If you don't set |
I'm setting this back to draft. I've submitted PR nispor/mozim#39 to mozim to fix the hostname issue and add a set_client_id() method so I'd like to see that get merged first. This way we don't need the workaround for setting the client id. |
bbc316c
to
bf8ec12
Compare
The last force push just updated the commit message. No code changes. |
bf8ec12
to
ef26b55
Compare
4c89534
to
d75fd36
Compare
@Luap99 When I run
Fedora 41 with...
|
I have not seen anything like this before. Is this only validate? The actual build works fine? |
Yeah, every other make target works fine. Ah well, no worries. I'll poke at it a bit. |
@Luap99 Just FYI... I had to switch to the nightly rust toolchain to get
|
New lint fixes for rust v1.83 are already in #1134 |
@Luap99 Do you guys have a policy on how to address upstream projects (nispor/mozim in this case) that aren't responsive? Think I should go back to my workaround for setting client id? It was...
|
We have to see, for now we all will be on PTO over the holidays and we are most likely aiming for our next release end of January/start of February. So until then there is plenty of time for him to react and merge it. We don't have any rules about it, often the answer is wait and hope. However in this case the maintainer is also working for Red Hat and we have been working with him in the past. I will send him an email and ask him to have a look. Maybe he just missed the notification. So for now just wait and we can see in January if we need to use the work around. |
Sounds good, thanks. |
I merged #1145 which includes your fixes |
…t id Currently, since a container's hostname isn't sent to netavark, we can't include it in DHCP requests when using a macvlan network and DHCP IPAM driver. Therefore, if DNS records need to be added for a container, it needs to be done by external scripts. Another issue is that since every time a container starts it gets a new random mac address and since, in the absense of a client id, the mac address is used by DHCP servers to keep track of leases, it's likely that the container will get a new ip address on restart. If the container is providing an exposed service, even just ssh, clients may have the old address cached and may not be able to reach the container. This commit accepts the container's hostname on incoming JSON setup commands and adds it to the DHCP client configuration so an Option 12 (Hostname) parameter can be sent in DHCP messages. This should allow DDNS updates of DNS resords. This is dependent on corresponding commits in Podman and common to actually pass the host name of course. This commit also sets the Option 61 (Client identifier) to the container's ID. Since this stays constant across container restarts, it's likely the DHCP server will use the existing lease and return the same IP address. * Added "container_hostname" to network::types::NetworkOptions. The setup command will set this from the incoming JSON and pass it through ultimately to dhcp_service::DhcpV4Service via macvlan_dhcp.get_dhcp_lease(). * Added "container_id" to proxy.proto so it can also be passed to dhcp_service::DhcpV4Service and used to set the client id. * Added tests to test-dhcp/002-setup.bats to check that hostname is passed correctly. Fixes: containers#676 Signed-off-by: George Joseph <[email protected]>
d75fd36
to
2bf9cfd
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gtjoseph The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for the assist @Luap99 ! |
Currently, since a container's hostname isn't sent to netavark, we can't
include it in DHCP requests when using a macvlan network and DHCP IPAM
driver. Therefore, if DNS records need to be added for a container, it needs
to be done by external scripts. Another issue is that since every time a
container starts it gets a new random mac address and since, in the absense
of a client id, the mac address is used by DHCP servers to keep track of
leases, it's likely that the container will get a new ip address on restart.
If the container is providing an exposed service, even just ssh, clients may
have the old address cached and may not be able to reach the container.
This commit accepts the container's hostname on incoming JSON setup commands
and adds it to the DHCP client configuration so an Option 12
(Hostname) parameter can be sent in DHCP messages. This should allow DDNS
updates of DNS resords. This is dependent on corresponding commits in Podman
and common to actually pass the host name of course. This commit also sets
the Option 61 (Client identifier) to the container's ID. Since this stays
constant across container restarts, it's likely the DHCP server will use the
existing lease and return the same IP address.
Added "container_hostname" to network::types::NetworkOptions. The setup
command will set this from the incoming JSON and pass it through ultimately
to dhcp_service::DhcpV4Service via macvlan_dhcp.get_dhcp_lease().
Added "container_id" to proxy.proto so it can also be passed to
dhcp_service::DhcpV4Service and used to set the client id.
Added tests to test-dhcp/002-setup.bats to check that hostname is passed
correctly.
Fixes: #676
Signed-off-by: George Joseph [email protected]
The new functionality requires the following PRs but netavark will build and run successfully with existing functionality without them.
containers/podman#24675
containers/common#2254
This PR DOES however require the following mozim PR to set the client id:
nispor/mozim#39