Don't populate NetDevs[].Type or NetDevs[].Netmask during upgrade

- Closes: #1661

NetDev defaults don't behave quite the same as standard fields, because they
need to be set per-device. Meanwhile, trying to set a value may erroneously
override values that are on the default profile.

Switch this to a warning rather than attempting to take explicit action.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-30 03:43:39 -07:00
committed by Christian Goll
parent 87b9ad33ff
commit 032db29f87
4 changed files with 28 additions and 8 deletions

View File

@@ -224,7 +224,15 @@ func (this *Node) Upgrade(addDefaults bool, replaceOverlays bool) (upgraded *nod
}
if this.NetDevs != nil {
for name, netDev := range this.NetDevs {
upgraded.NetDevs[name] = netDev.Upgrade(addDefaults)
upgraded.NetDevs[name] = netDev.Upgrade(false)
if addDefaults {
if upgraded.NetDevs[name].Type == "" {
wwlog.Warn("NetDevs[%s].Type not specified: verify default settings manually", name)
}
if len(upgraded.NetDevs[name].Netmask) == 0 {
wwlog.Warn("NetDevs[%s].Netmask not specified: verify default settings manually", name)
}
}
}
}
if this.PrimaryNetDev != "" {
@@ -630,7 +638,7 @@ func (this *NetDev) Upgrade(addDefaults bool) (upgraded *node.NetDev) {
upgraded.Type = "ethernet"
}
if upgraded.Netmask == nil {
upgraded.Netmask = net.ParseIP("255.255.255.0")
upgraded.Netmask = net.IP{255, 255, 255, 0}
}
}
return

View File

@@ -558,9 +558,7 @@ nodes:
- default
network devices:
default:
type: ethernet
ipaddr: 192.168.0.100
netmask: 255.255.255.0
`,
},
{
@@ -589,7 +587,6 @@ nodes:
network devices:
default:
ipaddr: 10.0.0.100
netmask: 255.255.0.0
`,
upgradedYaml: `
nodeprofiles:
@@ -625,13 +622,11 @@ nodes:
- custom
network devices:
default:
type: ethernet
ipaddr: 10.0.0.100
netmask: 255.255.0.0
`,
},
{
name: "add defaults conflicts",
name: "replace overlays conflicts",
addDefaults: false,
replaceOverlays: true,
legacyYaml: `