Port NFS before applying defaults
- Closes: #1758 Fixes an issue where `wwctl upgrade nodes` applied default NFS mounts and ported in NFS entries from warewulf.conf. Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
committed by
Christian Goll
parent
b41a49f863
commit
9cedd835aa
@@ -53,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Wait until ignition has completed before trying to mount.
|
||||
- Fix timeout problem for wwclient. #1741
|
||||
- Fixed default "true" state of NetDev.OnBoot. #1754
|
||||
- Port NFS mounts during `wwctl upgrade nodes` before applying defaults. #1758
|
||||
|
||||
### Removed
|
||||
|
||||
|
||||
@@ -67,6 +67,47 @@ func (legacy *NodesYaml) Upgrade(addDefaults bool, replaceOverlays bool, warewul
|
||||
wwlog.Warn("node %s does not include the default profile: verify default settings manually", name)
|
||||
}
|
||||
}
|
||||
if warewulfconf != nil && warewulfconf.NFS != nil {
|
||||
var fstab []map[string]string
|
||||
for _, export := range warewulfconf.NFS.Exports {
|
||||
fstab = append(fstab, map[string]string{
|
||||
"spec": fmt.Sprintf("warewulf:%s", export),
|
||||
"file": export,
|
||||
"vfstype": "nfs",
|
||||
})
|
||||
}
|
||||
for _, export := range warewulfconf.NFS.ExportsExtended {
|
||||
if export.Mount != nil && *(export.Mount) {
|
||||
entry := map[string]string{
|
||||
"spec": fmt.Sprintf("warewulf:%s", export.Path),
|
||||
"file": export.Path,
|
||||
"vfstype": "nfs",
|
||||
}
|
||||
if export.MountOptions != "" {
|
||||
entry["mntops"] = export.MountOptions
|
||||
}
|
||||
fstab = append(fstab, entry)
|
||||
}
|
||||
}
|
||||
if len(fstab) > 0 {
|
||||
if _, ok := upgraded.NodeProfiles["default"]; !ok {
|
||||
upgraded.NodeProfiles["default"] = new(node.Profile)
|
||||
}
|
||||
if upgraded.NodeProfiles["default"].Resources == nil {
|
||||
upgraded.NodeProfiles["default"].Resources = make(map[string]node.Resource)
|
||||
}
|
||||
if _, ok := upgraded.NodeProfiles["default"].Resources["fstab"]; ok {
|
||||
if prevFstab, ok := (upgraded.NodeProfiles["default"].Resources["fstab"]).([]map[string]string); ok {
|
||||
newFstab := append(prevFstab, fstab...)
|
||||
upgraded.NodeProfiles["default"].Resources["fstab"] = newFstab
|
||||
} else {
|
||||
wwlog.Warn("Unable to port NFS mounts from warewulf.conf: incompatible existing fstab resource in default profile")
|
||||
}
|
||||
} else {
|
||||
upgraded.NodeProfiles["default"].Resources["fstab"] = fstab
|
||||
}
|
||||
}
|
||||
}
|
||||
if addDefaults {
|
||||
if _, ok := upgraded.NodeProfiles["default"]; !ok {
|
||||
upgraded.NodeProfiles["default"] = new(node.Profile)
|
||||
@@ -113,47 +154,6 @@ func (legacy *NodesYaml) Upgrade(addDefaults bool, replaceOverlays bool, warewul
|
||||
}
|
||||
}
|
||||
}
|
||||
if warewulfconf != nil && warewulfconf.NFS != nil {
|
||||
var fstab []map[string]string
|
||||
for _, export := range warewulfconf.NFS.Exports {
|
||||
fstab = append(fstab, map[string]string{
|
||||
"spec": fmt.Sprintf("warewulf:%s", export),
|
||||
"file": export,
|
||||
"vfstype": "nfs",
|
||||
})
|
||||
}
|
||||
for _, export := range warewulfconf.NFS.ExportsExtended {
|
||||
if export.Mount != nil && *(export.Mount) {
|
||||
entry := map[string]string{
|
||||
"spec": fmt.Sprintf("warewulf:%s", export.Path),
|
||||
"file": export.Path,
|
||||
"vfstype": "nfs",
|
||||
}
|
||||
if export.MountOptions != "" {
|
||||
entry["mntops"] = export.MountOptions
|
||||
}
|
||||
fstab = append(fstab, entry)
|
||||
}
|
||||
}
|
||||
if len(fstab) > 0 {
|
||||
if _, ok := upgraded.NodeProfiles["default"]; !ok {
|
||||
upgraded.NodeProfiles["default"] = new(node.Profile)
|
||||
}
|
||||
if upgraded.NodeProfiles["default"].Resources == nil {
|
||||
upgraded.NodeProfiles["default"].Resources = make(map[string]node.Resource)
|
||||
}
|
||||
if _, ok := upgraded.NodeProfiles["default"].Resources["fstab"]; ok {
|
||||
if prevFstab, ok := (upgraded.NodeProfiles["default"].Resources["fstab"]).([]map[string]string); ok {
|
||||
newFstab := append(prevFstab, fstab...)
|
||||
upgraded.NodeProfiles["default"].Resources["fstab"] = newFstab
|
||||
} else {
|
||||
wwlog.Warn("Unable to port NFS mounts from warewulf.conf: incompatible existing fstab resource in default profile")
|
||||
}
|
||||
} else {
|
||||
upgraded.NodeProfiles["default"].Resources["fstab"] = fstab
|
||||
}
|
||||
}
|
||||
}
|
||||
return upgraded
|
||||
}
|
||||
|
||||
|
||||
@@ -880,6 +880,73 @@ nfs:
|
||||
mount: true
|
||||
- path: /var
|
||||
mount: false
|
||||
mount options: defaults
|
||||
- path: /srv
|
||||
mount options: defaults
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "Legacy extended export mounts with defaults",
|
||||
addDefaults: true,
|
||||
legacyYaml: `
|
||||
nodeprofiles:
|
||||
default: {}
|
||||
`,
|
||||
upgradedYaml: `
|
||||
nodeprofiles:
|
||||
default:
|
||||
ipxe template: default
|
||||
runtime overlay:
|
||||
- hosts
|
||||
- ssh.authorized_keys
|
||||
- syncuser
|
||||
system overlay:
|
||||
- wwinit
|
||||
- wwclient
|
||||
- fstab
|
||||
- hostname
|
||||
- ssh.host_keys
|
||||
- issue
|
||||
- resolv
|
||||
- udev.netname
|
||||
- systemd.netname
|
||||
- ifcfg
|
||||
- NetworkManager
|
||||
- debian.interfaces
|
||||
- wicked
|
||||
- ignition
|
||||
kernel:
|
||||
args:
|
||||
- quiet
|
||||
- crashkernel=no
|
||||
- vga=791
|
||||
- net.naming-scheme=v238
|
||||
init: /sbin/init
|
||||
root: initramfs
|
||||
resources:
|
||||
fstab:
|
||||
- spec: warewulf:/home
|
||||
file: /home
|
||||
vfstype: nfs
|
||||
- spec: warewulf:/opt
|
||||
file: /opt
|
||||
mntops: defaults,ro
|
||||
vfstype: nfs
|
||||
nodes: {}
|
||||
`,
|
||||
warewulfConf: `
|
||||
nfs:
|
||||
export paths:
|
||||
- path: /home
|
||||
mount: true
|
||||
- path: /opt
|
||||
mount options: defaults,ro
|
||||
mount: true
|
||||
- path: /var
|
||||
mount: false
|
||||
mount options: defaults
|
||||
- path: /srv
|
||||
mount options: defaults
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user