-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Pass container hostname to netavark #24675
base: main
Are you sure you want to change the base?
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
57d0866
to
aa649e7
Compare
The |
can you add a test? |
Sure, if you can give me some guidance on how to do it. I looked at the existing networking tests but none seemed appropriate to use as a template. From a podman perspective, all this new feature does is set the new ContainerHostname field in common's libnetwork NetworkOptions. The only true way to test this is to start a container with a macvlan network and dhcp ipam driver, then check the contents of the DHCP Discover packet. |
We don't have any DHCP tests here, that should all be tested in netavark as we already have a working DHCP setup there What you can and should test IMO is that your config field is working by setting that and then checking the hostname in the container (i.e. without any DHCP going on). That does not cover the code path passing the right thing to netavark but at least it should cover your basic logic here in podman |
Test created. |
aa649e7
to
fa6eba9
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 |
fa6eba9
to
44d3c3b
Compare
44d3c3b
to
2f722c8
Compare
Force push to fix gofmt issues and rebase to current main. |
2f722c8
to
5e2d38d
Compare
Holy Moly...checking for typos in comments. What a concept. :) --EDIT-- |
5e2d38d
to
c6a5ff2
Compare
I don't think the 4 failing tests are related to my change but if they are, let me know and I'll try and track them down. "testing-farm:fedora-rawhide-x86_64:cockpit-revdeps" at least looks like it has dependency issues when doing "dnf install". |
Passing the hostname allows netavark to include it in DHCP lease requests which, in an environment where DDNS is used, can cause DNS entries to be created automatically. * The current Hostname() function in container.go was updated to check the new `container_name_as_hostname` option in the CONTAINERS table of containers.conf. If set and no hostname was configured for the container, it causes the hostname to be set to a version of the container's name with the characters not valid for a hostname removed. If not set (the default), the original behavior of setting the hostname to the short container ID is preserved. * Because the Hostname() function can return the host's hostname if the container isn't running in a private UTS namespace, and we'd NEVER want to send _that_ in a DHCP request for a container, a new function NetworkHostname() was added which functions like Hostname() except that it will return an empty string instead of the host's hostname if the container is not running in a private UTS namespace. * networking_common.getNetworkOptions() now uses NetworkHostname() to set the ContainerHostname member of the NetworkOptions structure. That member was added to the structure in a corresponding commit in common/libnetwork/types/network.go. * Added test to containers_conf_test.go Signed-off-by: George Joseph <g.devel@wxy78.net>
c6a5ff2
to
bf5cb60
Compare
Rebased and, since the containers/common#2254 dependency was merged, the temporary DO NOT MERGE commit has been removed. Still waiting on netavark which is waiting on an upstream package PR. |
Passing the hostname allows netavark to include it in DHCP lease
requests which, in an environment where DDNS is used, can cause
DNS entries to be created automatically.
The current Hostname() function in container.go was updated to
check the new
container_name_as_hostname
option in theCONTAINERS table of containers.conf. If set and no hostname
was configured for the container, it causes the hostname to be
set to a version of the container's name with the characters not
valid for a hostname removed. If not set (the default), the original
behavior of setting the hostname to the short container ID is
preserved.
Because the Hostname() function can return the host's hostname
if the container isn't running in a private UTS namespace, and we'd
NEVER want to send that in a DHCP request for a container, a new
function NetworkHostname() was added which functions like Hostname()
except that it will return an empty string instead of the host's
hostname if the container is not running in a private UTS namespace.
networking_common.getNetworkOptions() now uses NetworkHostname()
to set the ContainerHostname member of the NetworkOptions structure.
That member was added to the structure in a corresponding commit in
common/libnetwork/types/network.go.
Added test to containers_conf_test.go
Signed-off-by: George Joseph g.devel@wxy78.net
NOTE:
Requires containers/common#2254
Required by containers/netavark#1130