From 037c456bc4d0c72b69862aa059367d521d241227 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 11 Nov 2022 10:24:15 -0600 Subject: [PATCH 1/2] Correct host overlay processing during configure wwctl configure hostfile was using the /host/ path twice, causing it to look in the wrong place for /etc/hosts.ww Signed-off-by: Jonathon Anderson --- internal/pkg/configure/hostfile.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/pkg/configure/hostfile.go b/internal/pkg/configure/hostfile.go index 15e0b7a8..5632ae9e 100644 --- a/internal/pkg/configure/hostfile.go +++ b/internal/pkg/configure/hostfile.go @@ -15,7 +15,8 @@ import ( Creates '/etc/hosts' from the host template. */ func Hostfile() error { - if !(util.IsFile(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))) { + hostTemplate := path.Join(overlay.OverlaySourceDir("host"), "/etc/hosts.ww") + if !(util.IsFile(hostTemplate)) { wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay") os.Exit(1) } @@ -24,13 +25,13 @@ func Hostfile() error { hostname, _ := os.Hostname() nodeInfo.Id.Set(hostname) buffer, backupFile, writeFile, err := overlay.RenderTemplateFile( - path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"), + hostTemplate, tstruct) if err != nil { wwlog.Error("%s", err) os.Exit(1) } - info, err := os.Stat(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww")) + info, err := os.Stat(hostTemplate) if err != nil { wwlog.Error("%s", err) os.Exit(1) From 15879eb99100aebc6b7fa9441a4e3f31fdcc689c Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 11 Nov 2022 10:45:14 -0600 Subject: [PATCH 2/2] Use node.NewInfo constructor in configure hostfile Also used in overlay, as I was looking there already. Signed-off-by: Jonathon Anderson --- internal/pkg/configure/hostfile.go | 5 +++-- internal/pkg/overlay/overlay.go | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/pkg/configure/hostfile.go b/internal/pkg/configure/hostfile.go index 5632ae9e..27866775 100644 --- a/internal/pkg/configure/hostfile.go +++ b/internal/pkg/configure/hostfile.go @@ -20,10 +20,11 @@ func Hostfile() error { wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay") os.Exit(1) } - var nodeInfo node.NodeInfo - tstruct := overlay.InitStruct(nodeInfo) + + nodeInfo := node.NewInfo() hostname, _ := os.Hostname() nodeInfo.Id.Set(hostname) + tstruct := overlay.InitStruct(nodeInfo) buffer, backupFile, writeFile, err := overlay.RenderTemplateFile( hostTemplate, tstruct) diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index b8e053e0..06ddc1fa 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -81,14 +81,11 @@ func BuildSpecificOverlays(nodes []node.NodeInfo, overlayNames []string) error { Build overlay for the host, so no argument needs to be given */ func BuildHostOverlay() error { - var host node.NodeInfo - host.Kernel = new(node.KernelEntry) - host.Ipmi = new(node.IpmiEntry) - var idEntry node.Entry + host := node.NewInfo() hostname, _ := os.Hostname() + host.Id.Set(hostname) + wwlog.Info("Building overlay for %s: host", hostname) - idEntry.Set(hostname) - host.Id = idEntry hostdir := OverlaySourceDir("host") stats, err := os.Stat(hostdir) if err != nil {