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:
committed by
Christian Goll
parent
87b9ad33ff
commit
032db29f87
@@ -885,6 +885,22 @@ nodes:
|
||||
fieldValues: []string{"ro1,ro2,~ro1,ro3", "so1,so2,so4,~so2"},
|
||||
sources: []string{"default,n1", "default,n1"},
|
||||
},
|
||||
"netmask inheritance": {
|
||||
nodesConf: `
|
||||
nodeprofiles:
|
||||
p1:
|
||||
network devices:
|
||||
default:
|
||||
netmask: 255.255.255.0
|
||||
nodes:
|
||||
n1:
|
||||
profiles:
|
||||
- p1`,
|
||||
node: "n1",
|
||||
field: "NetDevs[default].Netmask",
|
||||
source: "p1",
|
||||
value: "255.255.255.0",
|
||||
},
|
||||
}
|
||||
|
||||
for name, tt := range tests {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: `
|
||||
|
||||
Reference in New Issue
Block a user