Compare commits

..

No commits in common. "4c0a0c46e3642ed4643233a6b86c8af396ce708c" and "c4c3880718803b7527c0409afd02860fd45cffec" have entirely different histories.

1 changed files with 12 additions and 26 deletions

View File

@ -176,37 +176,22 @@ func setHostname(nm *nmlite.NetworkManager, hostname, domain string) error {
return nm.SetHostname(hostname, domain) return nm.SetHostname(hostname, domain)
} }
func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (rebootRequired bool, postRebootAction *PostRebootAction) { func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (bool, *PostRebootAction) {
oldDhcpClient := oldConfig.DHCPClient.String var rebootRequired bool
var postRebootAction *PostRebootAction
l := networkLogger.With(). oldDhcpClient := oldConfig.DHCPClient.String
Interface("old", oldConfig).
Interface("new", newConfig).
Logger()
// DHCP client change always requires reboot // DHCP client change always requires reboot
if newConfig.DHCPClient.String != oldDhcpClient { if newConfig.DHCPClient.String != oldDhcpClient {
rebootRequired = true rebootRequired = true
l.Info().Msg("DHCP client changed, reboot required") networkLogger.Info().Str("old", oldDhcpClient).Str("new", newConfig.DHCPClient.String).Msg("DHCP client changed, reboot required")
return rebootRequired, postRebootAction
} }
oldIPv4Mode := oldConfig.IPv4Mode.String
newIPv4Mode := newConfig.IPv4Mode.String
// IPv4 mode change requires reboot // IPv4 mode change requires reboot
if newIPv4Mode != oldIPv4Mode { if newConfig.IPv4Mode.String != oldConfig.IPv4Mode.String {
rebootRequired = true rebootRequired = true
l.Info().Msg("IPv4 mode changed with udhcpc, reboot required") networkLogger.Info().Str("old", oldConfig.IPv4Mode.String).Str("new", newConfig.IPv4Mode.String).Msg("IPv4 mode changed with udhcpc, reboot required")
if newIPv4Mode == "static" && oldIPv4Mode != "static" {
postRebootAction = &PostRebootAction{
HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String),
RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String),
}
l.Info().Interface("postRebootAction", postRebootAction).Msg("IPv4 mode changed to static, reboot required")
}
return rebootRequired, postRebootAction
} }
// IPv4 static config changes require reboot // IPv4 static config changes require reboot
@ -220,17 +205,18 @@ func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (re
HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String), HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String),
RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String), RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String),
} }
l.Info().Interface("postRebootAction", postRebootAction).Msg("IPv4 static config changed, reboot required")
} }
return rebootRequired, postRebootAction networkLogger.Info().
Interface("old", oldConfig.IPv4Static).
Interface("new", newConfig.IPv4Static).
Msg("IPv4 static config changed, reboot required")
} }
// IPv6 mode change requires reboot when using udhcpc // IPv6 mode change requires reboot when using udhcpc
if newConfig.IPv6Mode.String != oldConfig.IPv6Mode.String && oldDhcpClient == "udhcpc" { if newConfig.IPv6Mode.String != oldConfig.IPv6Mode.String && oldDhcpClient == "udhcpc" {
rebootRequired = true rebootRequired = true
l.Info().Msg("IPv6 mode changed with udhcpc, reboot required") networkLogger.Info().Str("old", oldConfig.IPv6Mode.String).Str("new", newConfig.IPv6Mode.String).Msg("IPv6 mode changed with udhcpc, reboot required")
} }
return rebootRequired, postRebootAction return rebootRequired, postRebootAction