-
Notifications
You must be signed in to change notification settings - Fork 202
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 new etchosts package #998
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Empty string for none for Will review the rest after lunch |
@mheon No rush. I want to work on the podman/buildah changes now before we merge this to make sure I have not missed something or need to tweak the interfaces a bit. |
:LGTM other then a few nits. |
330f607
to
b94788f
Compare
Podman PR: containers/podman#13918 I think I still have to change and add some tests in podman/buildah but this is ready. @mheon PTAL |
LGTM |
@vrothberg PTAL |
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.
Other than the docs nit, LGTM.
Nice work!
Add a new libnetwork/etchosts package to manage reading/writing hosts files. This package exports four functions New(), Add(), AddIfExists() and Remove(). See the godoc comments on the functions. Both podman and buildah should use this functions to make sure files are generated identical. Signed-off-by: Paul Holzinger <[email protected]>
base_hosts_file can be used to overwrite the default base host file /etc/hosts which is used to copy hosts entries from this file into the containers /etc/hosts file. As special value "image" can be used to copy the entries from the image hosts file or "none" to not use a base file at all. IF the value is empty we should use /etc/hosts as default. Ref containers/podman#13277 Ref containers/podman#13748 Signed-off-by: Paul Holzinger <[email protected]>
Set the ip for the host.containers.internal entry in the containers /etc/hosts file. This can be set to "none" to disable adding this entry. By default it will automatically choose the host ip. Also add a function to get the correct host.containers.internal ip. This should be used by podman and buildah and then passed to the New() function. Ref containers/podman#13224 Signed-off-by: Paul Holzinger <[email protected]>
Add function to get all host entries from a given network status. Signed-off-by: Paul Holzinger <[email protected]>
Add helper function to convert the base_hosts_file config value to a actual path. It is important to use securejoin to make sure that containers cannot point to a file on the hosts via a symlink. Signed-off-by: Paul Holzinger <[email protected]>
/lgtm |
/hold cancel |
Add a new libnetwork/etchosts package to manage reading/writing hosts files.
This package exports two functions New() and Add(). See the godoc comments
on the functions.
Both podman and buildah should use this function to make sure files are
generated identical.
libnetwork/util: add GetNetworkIPs()
Add helper function to get the first ipv4 and ipv6 from the network
status. Since this is stored as a map, calling this function multiple
times is not deterministic. The caller (Podman) should store this result
to make sure it will keep using the same ips.
add base_hosts_file field to containers.conf
base_hosts_file can be used to overwrite the default base host file
/etc/hosts which is used to copy hosts entries from this file into the
containers /etc/hosts file. As special value "image" can be used to copy
the entries from the image hosts file or an empty string "" to not use a
base file at all.
Ref containers/podman#13277
Ref containers/podman#13748
add host_containers_internal_ip to containers.conf
Set the ip for the host.containers.internal entry in the containers /etc/hosts
file. This can be set to "none" to disable adding this entry. By default it
will automatically choose the host ip.
Also add a function to get the correct host.containers.internal ip. This
should be used by podman and buildah and then passed to the New()
function.
Ref containers/podman#13224