Skip to content

Commit

Permalink
Refactor kernel support
Browse files Browse the repository at this point in the history
- Remove kernel imports and kmods images
- Repurpose KernelOverride as container path
- Support Kernel.Version as version prefix for kernel selection
- Compare initramfs by version

Signed-off-by: Jonathon Anderson <[email protected]>
  • Loading branch information
anderbubble authored and mslacken committed Dec 9, 2024
1 parent d87ed27 commit 8f21d54
Show file tree
Hide file tree
Showing 40 changed files with 965 additions and 972 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Better handling of InfiniBand udev net naming. #1227
- use templating mechanism for power commands. #1004
- Document "known issues."
- Add `wwctl <node|profile> <add|set> --kernelversion` to specify the desired kernel version. #1556

### Changed

Expand Down Expand Up @@ -72,6 +73,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Bump github.com/Masterminds/sprig/v3 from 3.2.3 to 3.3.0 #1553
- Bump github.com/golang/glog from 1.2.0 to 1.2.3 #1527
- Bump github.com/opencontainers/runc from 1.1.12 to 1.1.14
- Repurpose Kernel.Override to specify the path to the desired kernel within the container. #1556
- Repurpose `wwctl kernel list` to list discovered kernels from containers. #1556

### Removed

Expand All @@ -80,6 +83,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Remove `wwctl server <start,stop,status,restart,reload>` #508
- Remove `wwctl overlay build --host` #1419
- Remove `wwctl overlay build --nodes` #1419
- Remove `wwctl kernel <import|delete>` #1556

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion dracut/modules.d/90wwinit/load-wwinit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
info "Mounting tmpfs at $NEWROOT"
mount -t tmpfs -o mpol=interleave ${wwinit_tmpfs_size_option} tmpfs "$NEWROOT"

for archive in "${wwinit_container}" "${wwinit_kmods}" "${wwinit_system}" "${wwinit_runtime}"
for archive in "${wwinit_container}" "${wwinit_system}" "${wwinit_runtime}"
do
if [ -n "${archive}" ]
then
Expand Down
4 changes: 0 additions & 4 deletions dracut/modules.d/90wwinit/parse-wwinit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ then
export wwinit_container="${wwinit_uri}&stage=container&compress=gz"; info "wwinit_container=${wwinit_container}"
export wwinit_system="${wwinit_uri}&stage=system&compress=gz"; info "wwinit_system=${wwinit_system}"
export wwinit_runtime="${wwinit_uri}&stage=runtime&compress=gz"; info "wwinit_runtime=${wwinit_runtime}"
if [ -n "$(getarg wwinit.KernelOverride)" ]
then
export wwinit_kmods="${wwinit_uri}&stage=kmods&compress=gz"; info "wwinit_kmods=${wwinit_kmods}"
fi

wwinit_tmpfs_size=$(getarg wwinit.tmpfs.size=)
if [ -n "$wwinit_tmpfs_size" ]
Expand Down
20 changes: 0 additions & 20 deletions etc/ipxe/default.ipxe
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ imgextract --name system ${uri_base}&stage=system&compress=gz || goto rebo
echo Downloading Runtime Overlay:
imgextract --name runtime ${uri_base}&stage=runtime&compress=gz && set runtime_initrd initrd=runtime || echo Failed downloading runtime overlay.

{{if ne .KernelOverride "" -}}
echo Downloading Kernel Modules:
imgextract --name kmods ${uri_base}&stage=kmods&compress=gz || goto reboot
{{- end}}

goto imoktogo

:nocompress
Expand All @@ -60,11 +55,6 @@ initrd --name system ${uri_base}&stage=system || goto reboot
echo Downloading Runtime Overlay:
initrd --name runtime ${uri_base}&stage=runtime && set runtime_initrd initrd=runtime || echo Failed downloading runtime overlay.

{{if ne .KernelOverride "" -}}
echo Downloading Kernel Modules:
initrd --name kmods ${uri_base}&stage=kmods || goto reboot
{{- end}}

goto imoktogo

:noefi
Expand All @@ -81,21 +71,11 @@ initrd --name system ${uri_base}&stage=system&compress=gz || goto reboot
echo Downloading Runtime Overlay:
initrd --name runtime ${uri_base}&stage=runtime&compress=gz && set runtime_initrd initrd=runtime || echo Failed downloading runtime overlay.

{{if ne .KernelOverride "" -}}
echo Downloading Kernel Modules:
initrd --name kmods ${uri_base}&stage=kmods&compress=gz || goto reboot
{{- end}}


:imoktogo

{{if ne .KernelOverride "" -}}
echo boot kernel initrd=container initrd=kmods initrd=system ${runtime_initrd} wwid={{.Hwaddr}} {{.KernelArgs}}
boot kernel initrd=container initrd=kmods initrd=system ${runtime_initrd} wwid={{.Hwaddr}} {{.KernelArgs}} || goto reboot
{{- else -}}
echo boot kernel initrd=container initrd=system ${runtime_initrd} wwid={{.Hwaddr}} {{.KernelArgs}}
boot kernel initrd=container initrd=system ${runtime_initrd} wwid={{.Hwaddr}} {{.KernelArgs}} || goto reboot
{{- end}}

:reboot
echo
Expand Down
13 changes: 2 additions & 11 deletions etc/ipxe/dracut.ipxe
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,14 @@ echo Warewulf Controller: {{.Ipaddr}}
echo Downloading Kernel Image:
kernel --name kernel ${uri}&stage=kernel || goto reboot

{{if ne .KernelOverride ""}}
echo Downloading Kernel Modules:
imgextract --name kmods ${uri}&stage=kmods&compress=gz || initrd --name kmods ${uri}&stage=kmods || goto reboot
set kernel_mods initrd=kmods
{{end}}

echo Downloading initramfs
initrd --name initramfs ${uri}&stage=initramfs || goto reboot

set dracut_net rd.neednet=1 {{range $devname, $netdev := .NetDevs}}{{if and $netdev.Hwaddr $netdev.Device}} ifname={{$netdev.Device}}:{{$netdev.Hwaddr}} {{end}}{{end}}
set dracut_wwinit root=wwinit wwinit.uri=${baseuri} {{if ne .KernelOverride ""}}wwinit.KernelOverride={{ .KernelOverride }}{{end}} init=/init
set dracut_wwinit root=wwinit wwinit.uri=${baseuri} init=/init

echo Booting initramfs
#echo Network KernelArgs: ${dracut_net}
#echo Dracut wwinit KernelArgs: ${dracut_wwinit}
#sleep 15
boot kernel initrd=initramfs ${kernel_mods} ${dracut_net} ${dracut_wwinit} wwid={{.Hwaddr}} {{.KernelArgs}}
boot kernel initrd=initramfs ${dracut_net} ${dracut_wwinit} wwid={{.Hwaddr}} {{.KernelArgs}}


:reboot
Expand Down
87 changes: 87 additions & 0 deletions internal/app/wwctl/completions/completions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package completions

import (
"github.com/spf13/cobra"

"github.com/warewulf/warewulf/internal/pkg/hostlist"
"github.com/warewulf/warewulf/internal/pkg/kernel"
"github.com/warewulf/warewulf/internal/pkg/node"
)

func NodeKernelOverride(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var kernelPaths []string
registry, err := node.New()
if err != nil {
return kernelPaths, cobra.ShellCompDirectiveNoFileComp
}
nodes := hostlist.Expand(args)
for _, id := range nodes {
if node_, err := registry.GetNode(id); err != nil {
continue
} else if node_.ContainerName != "" {
kernels := kernel.FindKernels(node_.ContainerName)
for _, kernel_ := range kernels {
kernelPaths = append(kernelPaths, kernel_.Path)
}
}
}
return kernelPaths, cobra.ShellCompDirectiveNoFileComp
}

func NodeKernelVersion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var kernelVersions []string
registry, err := node.New()
if err != nil {
return kernelVersions, cobra.ShellCompDirectiveNoFileComp
}
nodes := hostlist.Expand(args)
for _, id := range nodes {
if node_, err := registry.GetNode(id); err != nil {
continue
} else if node_.ContainerName != "" {
kernels := kernel.FindKernels(node_.ContainerName)
for _, kernel_ := range kernels {
kernelVersions = append(kernelVersions, kernel_.Version())
}
}
}
return kernelVersions, cobra.ShellCompDirectiveNoFileComp
}

func ProfileKernelOverride(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var kernelPaths []string
registry, err := node.New()
if err != nil {
return kernelPaths, cobra.ShellCompDirectiveNoFileComp
}
for _, id := range args {
if profile, err := registry.GetProfile(id); err != nil {
continue
} else if profile.ContainerName != "" {
kernels := kernel.FindKernels(profile.ContainerName)
for _, kernel_ := range kernels {
kernelPaths = append(kernelPaths, kernel_.Path)
}
}
}
return kernelPaths, cobra.ShellCompDirectiveNoFileComp
}

func ProfileKernelVersion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var kernelVersions []string
registry, err := node.New()
if err != nil {
return kernelVersions, cobra.ShellCompDirectiveNoFileComp
}
for _, id := range args {
if profile, err := registry.GetProfile(id); err != nil {
continue
} else if profile.ContainerName != "" {
kernels := kernel.FindKernels(profile.ContainerName)
for _, kernel_ := range kernels {
kernelVersions = append(kernelVersions, kernel_.Version())
}
}
}
return kernelVersions, cobra.ShellCompDirectiveNoFileComp
}
1 change: 1 addition & 0 deletions internal/app/wwctl/container/list/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ nodes:
warewulfd.SetNoDaemon()
for _, tt := range tests {
env := testenv.New(t)
defer env.RemoveAll(t)
env.WriteFile(t, "etc/warewulf/nodes.conf", tt.inDb)

t.Logf("Running test: %s\n", tt.name)
Expand Down
39 changes: 0 additions & 39 deletions internal/app/wwctl/kernel/delete/main.go

This file was deleted.

34 changes: 0 additions & 34 deletions internal/app/wwctl/kernel/delete/root.go

This file was deleted.

80 changes: 0 additions & 80 deletions internal/app/wwctl/kernel/imprt/main.go

This file was deleted.

Loading

0 comments on commit 8f21d54

Please sign in to comment.