-
Notifications
You must be signed in to change notification settings - Fork 228
Fix containerd resolv.conf + DHCP behavior #441
Conversation
// - maybe we can use containerd.NewContainerOpts{} to do it just-in-time | ||
// - write this file to snapshot mount instead of vmDir | ||
// - commit snapshot? | ||
// - deprecate vm id from this function's signature |
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.
This extensive TODO
is here for posterity, but I can move it into an issue or just remove it altogether depending on what we want.
@@ -0,0 +1,201 @@ | |||
package resolvconf |
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.
This is its own package because it's very decoupled from runtime needs.
I couldn't find a more sensible home for it.
Also, not including it in runtime/containerd
allows you to run the tests without root.
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.
Yes. I have no problem with this in a separate package :-)
@@ -0,0 +1,201 @@ | |||
package resolvconf |
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.
Yes. I have no problem with this in a separate package :-)
|
||
// WriteFileIfChanged stores a sha of data at <filename>.sha256 and determines whether to | ||
// rewrite the file; it has the same signature as ioutil.WriteFile(). | ||
func WriteFileIfChanged(filename string, data []byte, perm os.FileMode) error { |
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.
I like this function!
} | ||
|
||
if isSystemdResolved(cfg) { | ||
systemdCfg, err := dns.ClientConfigFromFile(resolvSystemd) |
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.
This systemd bit could also solve my problem too.
Fixes #437
Patches:
Having the user be able to setup custom DNS is great, but it would be better if it first worked well without any tweaking.
This resolv.conf library supports
/etc/resolv.conf
, systemd-resolved, and will even work with nothing at all.All loopback nameservers are filtered, and in the event that there's still no usable DNS, it falls back to Google DNS servers. (other default suggestions are welcome)
The containerd runtime then uses this lib to populate the vmDir specfic to the ignite vm's id.
A modification to the runtime interface was needed to pass the id so this could be done.
It might be better to try and use the container's snapshot instead of the vmDir to accomplish this.
However, using the vmDir is a generic solution since adding mounts for the runtime container is simple.
We could use this mechanism to more uniformly configure DHCP /w docker while disabling the default resolver for ignite-spawn as mentioned in #438.
I'd also be fine not actually writing any file and just adding fields to the vm manifest for
dhcp.Nameservers
anddhcp.Search
.We can still use readDNSConfig() and its accompanying functions to calculate the proper values from the host.
The benefit of using
/etc/resolv.conf
is it's well integrated with docker networks which the vm will benefit from through it's DHCP config.example behavior: