fix(networkd): Fix incorrect resolver settings
This modifies the way the hostname gets set. Previously, we would run through the entire addressing and resolver configuration and then set the hostname. This is problematic because the resolver depends on the functionality of Hostname() ( resolver configuration relies on the domainname of the host ). Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
This commit is contained in:
parent
fedcf13c42
commit
93218687ec
@ -38,5 +38,5 @@ func (task *InitialNetworkSetup) runtime(r runtime.Runtime) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
return nwd.Hostname()
|
||||
return nil
|
||||
}
|
||||
|
@ -91,6 +91,11 @@ func (n *Networkd) Runner(config runtime.Configurator) (runner.Runner, error) {
|
||||
env = append(env, fmt.Sprintf("%s=%s", key, val))
|
||||
}
|
||||
|
||||
// This is really only here to support container runtime
|
||||
if p, ok := os.LookupEnv("PLATFORM"); ok {
|
||||
env = append(env, fmt.Sprintf("%s=%s", "PLATFORM", p))
|
||||
}
|
||||
|
||||
return restart.New(containerd.NewRunner(
|
||||
config.Debug(),
|
||||
&args,
|
||||
|
@ -243,11 +243,22 @@ func (n *Networkd) Configure() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set hostname must be before the resolv configuration
|
||||
// so we can ensure the hosts domainname is set properly
|
||||
// before we write the search stanza
|
||||
if err = n.Hostname(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(resolvers) == 0 {
|
||||
resolvers = n.resolvers
|
||||
}
|
||||
|
||||
return writeResolvConf(resolvers)
|
||||
if err = writeResolvConf(resolvers); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Renew sets up a long running loop to refresh a network interfaces
|
||||
@ -284,14 +295,24 @@ func (n *Networkd) Hostname() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
var p runtime.Platform
|
||||
|
||||
p, err = platform.CurrentPlatform()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Skip hostname/domainname setting when running in container mode
|
||||
if p.Mode() == runtime.Container {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err = unix.Sethostname([]byte(hostname)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if domainname != "" {
|
||||
if err = unix.Setdomainname([]byte(domainname)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = unix.Setdomainname([]byte(domainname)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user