mirror of
https://github.com/rancher/os.git
synced 2025-06-27 07:16:48 +00:00
Add dhcp timeout parameter
This commit is contained in:
parent
a088811de9
commit
ef663b4e70
@ -284,12 +284,18 @@ func getDatasources(datasources []string) []datasource.Datasource {
|
||||
}
|
||||
|
||||
func enableDoLinkLocal() {
|
||||
cfg := rancherConfig.LoadConfig()
|
||||
dhcpTimeout := cfg.Rancher.Defaults.Network.DHCPTimeout
|
||||
if cfg.Rancher.Network.DHCPTimeout > 0 {
|
||||
dhcpTimeout = cfg.Rancher.Network.DHCPTimeout
|
||||
}
|
||||
_, err := netconf.ApplyNetworkConfigs(&netconf.NetworkConfig{
|
||||
Interfaces: map[string]netconf.InterfaceConfig{
|
||||
"eth0": {
|
||||
IPV4LL: true,
|
||||
},
|
||||
},
|
||||
DHCPTimeout: dhcpTimeout,
|
||||
}, false, false)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to apply link local on eth0: %v", err)
|
||||
|
@ -42,6 +42,9 @@ func ApplyNetworkConfig(cfg *config.CloudConfig) {
|
||||
}
|
||||
|
||||
userSetHostname := cfg.Hostname != ""
|
||||
if cfg.Rancher.Network.DHCPTimeout <= 0 {
|
||||
cfg.Rancher.Network.DHCPTimeout = cfg.Rancher.Defaults.Network.DHCPTimeout
|
||||
}
|
||||
dhcpSetDNS, err := netconf.ApplyNetworkConfigs(&cfg.Rancher.Network, userSetHostname, userSetDNS)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to apply network configs(by netconf): %v", err)
|
||||
|
@ -81,6 +81,7 @@ var schema = `{
|
||||
|
||||
"properties": {
|
||||
"pre_cmds": {"$ref": "#/definitions/list_of_strings"},
|
||||
"dhcp_timeout": {"type": "integer"},
|
||||
"dns": {"type": "object"},
|
||||
"interfaces": {"type": "object"},
|
||||
"post_cmds": {"$ref": "#/definitions/list_of_strings"},
|
||||
|
@ -14,6 +14,7 @@ rancher:
|
||||
engine: docker-18.03.1-ce
|
||||
{{end -}}
|
||||
network:
|
||||
dhcp_timeout: 10
|
||||
dns:
|
||||
nameservers: [8.8.8.8, 8.8.4.4]
|
||||
system_docker_logs: /var/log/system-docker.log
|
||||
|
@ -13,6 +13,13 @@ func CloudInit(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
stateConfig := config.LoadConfigWithPrefix(config.StateDir)
|
||||
cfg.Rancher.CloudInit.Datasources = stateConfig.Rancher.CloudInit.Datasources
|
||||
|
||||
if stateConfig.Rancher.Network.DHCPTimeout > 0 {
|
||||
cfg.Rancher.Network.DHCPTimeout = stateConfig.Rancher.Network.DHCPTimeout
|
||||
if err := config.Set("rancher.network.dhcp_timeout", stateConfig.Rancher.Network.DHCPTimeout); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(stateConfig.Rancher.Network.Interfaces) > 0 {
|
||||
cfg.Rancher.Network = stateConfig.Rancher.Network
|
||||
if err := config.Set("rancher.network", stateConfig.Rancher.Network); err != nil {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
@ -290,6 +291,10 @@ func runDhcp(netCfg *NetworkConfig, iface string, argstr string, setHostname, se
|
||||
args = append(args, "--nohook", "resolv.conf")
|
||||
}
|
||||
|
||||
if netCfg.DHCPTimeout > 0 {
|
||||
args = append(args, "--timeout", strconv.Itoa(netCfg.DHCPTimeout))
|
||||
}
|
||||
|
||||
// Wait for lease
|
||||
// TODO: this should be optional - based on kernel arg?
|
||||
args = append(args, "-w", "--debug")
|
||||
|
@ -2,6 +2,7 @@ package netconf
|
||||
|
||||
type NetworkConfig struct {
|
||||
PreCmds []string `yaml:"pre_cmds,omitempty"`
|
||||
DHCPTimeout int `yaml:"dhcp_timeout,omitempty"`
|
||||
DNS DNSConfig `yaml:"dns,omitempty"`
|
||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostCmds []string `yaml:"post_cmds,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user