Rename "preferred" kernel to "default" kernel

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-12-05 13:28:08 -07:00
committed by Christian Goll
parent 6f4d33b19e
commit facba28e0f
6 changed files with 38 additions and 38 deletions

View File

@@ -40,18 +40,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
t := table.New(cmd.OutOrStdout())
t.AddHeader("Container", "Kernel", "Version", "Preferred", "Nodes")
t.AddHeader("Container", "Kernel", "Version", "Default", "Nodes")
for _, source := range sources {
containerKernels := kernel.FindKernels(source)
preferredKernel := containerKernels.Preferred()
defaultKernel := containerKernels.Default()
for _, kernel_ := range containerKernels {
preferred := preferredKernel != nil && preferredKernel == kernel_
preferredStr := strconv.FormatBool(preferred)
isDefault := defaultKernel != nil && defaultKernel == kernel_
defaultStr := strconv.FormatBool(isDefault)
nodeCount := kernelNodes[*kernel_]
if preferred {
if isDefault {
nodeCount = nodeCount + kernelNodes[kernel.Kernel{ContainerName: source, Path: ""}]
}
t.AddLine(table.Prep([]string{source, kernel_.Path, kernel_.Version(), preferredStr, strconv.Itoa(nodeCount)})...)
t.AddLine(table.Prep([]string{source, kernel_.Path, kernel_.Version(), defaultStr, strconv.Itoa(nodeCount)})...)
}
}
t.Print()

View File

@@ -21,8 +21,8 @@ func Test_List(t *testing.T) {
files: map[string][]string{},
args: []string{},
stdout: `
Container Kernel Version Preferred Nodes
--------- ------ ------- --------- -----
Container Kernel Version Default Nodes
--------- ------ ------- ------- -----
`,
},
"list": {
@@ -42,16 +42,16 @@ Container Kernel Version Preferred Nodes
},
args: []string{},
stdout: `
Container Kernel Version Preferred Nodes
--------- ------ ------- --------- -----
container1 /boot/vmlinuz-4.14.0-427.18.1.el8_4.x86_64 4.14.0-427.18.1 false 0
container1 /boot/vmlinuz-5.14.0-427.18.1.el9_4.x86_64 5.14.0-427.18.1 false 0
container1 /boot/vmlinuz-5.14.0-427.24.1.el9_4.x86_64 5.14.0-427.24.1 true 0
container2 /boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0 -- false 0
container2 /boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64 5.14.0-284.30.1 false 0
container2 /boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64 5.14.0-362.24.1 false 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64 5.14.0-427.31.1 true 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.31.1 false 0
Container Kernel Version Default Nodes
--------- ------ ------- ------- -----
container1 /boot/vmlinuz-4.14.0-427.18.1.el8_4.x86_64 4.14.0-427.18.1 false 0
container1 /boot/vmlinuz-5.14.0-427.18.1.el9_4.x86_64 5.14.0-427.18.1 false 0
container1 /boot/vmlinuz-5.14.0-427.24.1.el9_4.x86_64 5.14.0-427.24.1 true 0
container2 /boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0 -- false 0
container2 /boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64 5.14.0-284.30.1 false 0
container2 /boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64 5.14.0-362.24.1 false 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64 5.14.0-427.31.1 true 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.31.1 false 0
`,
},
"single container": {
@@ -71,13 +71,13 @@ container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.
},
args: []string{"container2"},
stdout: `
Container Kernel Version Preferred Nodes
--------- ------ ------- --------- -----
container2 /boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0 -- false 0
container2 /boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64 5.14.0-284.30.1 false 0
container2 /boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64 5.14.0-362.24.1 false 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64 5.14.0-427.31.1 true 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.31.1 false 0
Container Kernel Version Default Nodes
--------- ------ ------- ------- -----
container2 /boot/vmlinuz-0-rescue-eb46964329b146e39518c625feab3ea0 -- false 0
container2 /boot/vmlinuz-5.14.0-284.30.1.el9_2.aarch64 5.14.0-284.30.1 false 0
container2 /boot/vmlinuz-5.14.0-362.24.1.el9_3.aarch64 5.14.0-362.24.1 false 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64 5.14.0-427.31.1 true 0
container2 /boot/vmlinuz-5.14.0-427.31.1.el9_4.aarch64+debug 5.14.0-427.31.1 false 0
`,
},
}

View File

@@ -305,7 +305,7 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
}
wwlog.Debug("Finding kernel version for: %s", source)
kernel := kernel.FindKernels(source).Preferred()
kernel := kernel.FindKernels(source).Default()
kernelVersion := ""
if kernel != nil {
kernelVersion = kernel.Version()
@@ -363,7 +363,7 @@ func ContainerShow(csp *wwapiv1.ContainerShowParameter) (response *wwapiv1.Conta
err = fmt.Errorf("%s is not a valid container", containerName)
return
}
kernel := kernel.FindKernels(containerName).Preferred()
kernel := kernel.FindKernels(containerName).Default()
kernelVersion := ""
if kernel != nil {
kernelVersion = kernel.Version()

View File

@@ -44,7 +44,7 @@ func (k collection) Sort() {
sort.Sort(k)
}
func (k collection) Preferred() *Kernel {
func (k collection) Default() *Kernel {
nk := append(collection{}, k...)
sort.Sort(sort.Reverse(nk))
for _, kernel := range nk {
@@ -83,7 +83,7 @@ func FromNode(node *node.Node) *Kernel {
return FindKernels(node.ContainerName).Version(node.Kernel.Version)
}
} else {
return FindKernels(node.ContainerName).Preferred()
return FindKernels(node.ContainerName).Default()
}
}

View File

@@ -96,7 +96,7 @@ func Test_FindKernel(t *testing.T) {
kernels := FindKernels("testcontainer")
assert.Equal(t, len(tt.files), len(kernels))
kernel := kernels.Preferred()
kernel := kernels.Default()
if tt.version == "" && tt.path == "" {
assert.Nil(t, kernel)
} else {

View File

@@ -13,14 +13,14 @@ You can see what kernels are available in imported containers by using the
.. code-block:: console
# wwctl container kernels
Container Kernel Version Preferred Nodes
--------- ------ ------- --------- -----
newroot-test /boot/vmlinuz-5.14.0-427.37.1.el9_4.aarch64 5.14.0-427.37.1 true 0
newroot-test /lib/modules/5.14.0-427.37.1.el9_4.aarch64/vmlinuz 5.14.0-427.37.1 false 0
rocky-8 /boot/vmlinuz-4.18.0-372.13.1.el8_6.x86_64 4.18.0-372.13.1 true 2
rocky-8 /lib/modules/4.18.0-372.13.1.el8_6.x86_64/vmlinuz 4.18.0-372.13.1 false 0
rocky-9.3 /lib/modules/5.14.0-362.13.1.el9_3.aarch64/vmlinuz 5.14.0-362.13.1 true 0
rockylinux-9-custom /lib/modules/5.14.0-427.40.1.el9_4.aarch64/vmlinuz 5.14.0-427.40.1 true 0
Container Kernel Version Default Nodes
--------- ------ ------- ------- -----
newroot-test /boot/vmlinuz-5.14.0-427.37.1.el9_4.aarch64 5.14.0-427.37.1 true 0
newroot-test /lib/modules/5.14.0-427.37.1.el9_4.aarch64/vmlinuz 5.14.0-427.37.1 false 0
rocky-8 /boot/vmlinuz-4.18.0-372.13.1.el8_6.x86_64 4.18.0-372.13.1 true 2
rocky-8 /lib/modules/4.18.0-372.13.1.el8_6.x86_64/vmlinuz 4.18.0-372.13.1 false 0
rocky-9.3 /lib/modules/5.14.0-362.13.1.el9_3.aarch64/vmlinuz 5.14.0-362.13.1 true 0
rockylinux-9-custom /lib/modules/5.14.0-427.40.1.el9_4.aarch64/vmlinuz 5.14.0-427.40.1 true 0
Kernel Version
==============