-
Notifications
You must be signed in to change notification settings - Fork 94
wip: atomic updates to /etc/hosts #537
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kevin Klues <[email protected]>
Signed-off-by: Kevin Klues <[email protected]>
Without this the IMEX daemons were getting confused if the same DNS name was used to by different nodes to point to differernt IMEX daemons in the ensemble. Signed-off-by: Kevin Klues <[email protected]>
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
|
Strongly related ref docs:
|
|
Interesting. I suppose we could create a minimal chroot environment inside our container with our own /etc/hosts file, the binaries we want to execute and any dependent libs. Seems a bit overkill but it would probably work. |
Interesting idea. So, that would give us full control over /etc/hosts without having to (un)mount anything. But how can we chroot without root privileges? |
|
you can chroot without privileges so long as the folder you are chrooting to doesnt require root. The problem is that you can't mount in the necessary /proc /sys dirs without being root. |
This is based on #433.
Before discussing code specifics (such as maybe putting code into
pkg/, whether or not to useotiai10/copy, ...) we need to talk about the high-level strategy.The strategy currently implemented by the patch works (tested), but contains a bit of a surprising detour.
I've captured the details in code comments, but want to summarize here, too:
rename()fails when the target is a mount target:/etc/hosts: device or resource busy/etc/hoststo be mounted into the container (managed by the container runtime)/etc/hostsperformed by the container runtime after CD daemon startup: one way to ensure that is to remove the mount./etc/hostsin the container early after startup: i) enable/etc/hostsas arename()target and ii) guarantee that we own and manage the file.So, this patch upon CD daemon startup (in order)
/etc/hostscontents/etc/hostsexactly as before the unmount (same content and permissions), just as a regular fileThe downside is that unmount requires root privileges, and hence for now I added
privileged: trueto the pod spec. I don't feel great about this.Our concern of performing atomic updates to this file in view of a mount and cross-ownership between host and container is certainly shared by many others. Some of the best discussion is in here: moby/moby#46908 (comment)
Two high-level thoughts:
/etc/hostsupdates initiated from the host from our big picture. This speaks in favor of unmount.Edit: an alternative to /etc/hosts at a different path would be great.
The C lib functions gethostbyname and getaddrinfo support HOSTALIASES as documented in https://man7.org/linux/man-pages/man7/hostname.7.html. Most notably, this files does not allow for mapping DNS names to IP addresses:
(https://blog.tremily.us/posts/HOSTALIASES/)