Skip to content

Commit

Permalink
Fix handling of unknown kernels (#670) (#933)
Browse files Browse the repository at this point in the history
Fix scheduling data generation for nodes that run an unconfigured
kernel and do not have the kmod loaded yet.

Upstream-Commit: a29ecc3

Co-authored-by: Quentin Barrand <[email protected]>
  • Loading branch information
github-actions[bot] and qbarrand authored Dec 19, 2023
1 parent 1ac1c76 commit 78a172a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 5 additions & 3 deletions internal/controllers/module_nmc_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,11 @@ func prepareNodeSchedulingData(node v1.Node, mld *api.ModuleLoaderData, currentN
versionLabel, present = utils.GetNodeWorkerPodVersionLabel(node.GetLabels(), mld.Namespace, mld.Name)
}
switch {
case mld == nil && currentNMCs.Has(node.Name):
// mld missing, Module does not have mapping for node's kernel, NMC for the node exists
return schedulingData{action: actionDelete}
case mld == nil:
if currentNMCs.Has(node.Name) {
// mld missing, Module does not have mapping for node's kernel, NMC for the node exists
return schedulingData{action: actionDelete}
}
case mld.ModuleVersion == "":
// mld exists, Version not define, should be running
return schedulingData{action: actionAdd, mld: mld, node: &node}
Expand Down
27 changes: 19 additions & 8 deletions internal/controllers/module_nmc_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,27 @@ var _ = Describe("prepareSchedulingData", func() {
Expect(scheduleData).To(Equal(map[string]schedulingData{}))
})

It("mld for kernel version does not exists", func() {
currentNMCs := sets.New[string](nodeName)
mockKernel.EXPECT().GetModuleLoaderDataForKernel(&mod, kernelVersion).Return(nil, module.ErrNoMatchingKernelMapping)
DescribeTable(
"mld for kernel version does not exists",
func(moduleCurrentlyEnabled bool, expectedAction string) {
currentNMCs := sets.New[string]()
expectedScheduleData := map[string]schedulingData{nodeName: {action: expectedAction}}

scheduleData, errs := mnrh.prepareSchedulingData(ctx, &mod, targetedNodes, currentNMCs)
if moduleCurrentlyEnabled {
currentNMCs.Insert(nodeName)
}

expectedScheduleData := map[string]schedulingData{nodeName: schedulingData{action: actionDelete}}
Expect(errs).To(BeEmpty())
Expect(scheduleData).To(Equal(expectedScheduleData))
})
mockKernel.EXPECT().GetModuleLoaderDataForKernel(&mod, kernelVersion).Return(nil, module.ErrNoMatchingKernelMapping)

scheduleData, errs := mnrh.prepareSchedulingData(ctx, &mod, targetedNodes, currentNMCs)

Expect(errs).To(BeEmpty())
Expect(scheduleData).To(Equal(expectedScheduleData))
},
EntryDescription("module currently enabled in MLD: %t, expected action: %q"),
Entry(nil, true, actionDelete),
Entry(nil, false, ""),
)

It("mld exists", func() {
currentNMCs := sets.New[string](nodeName)
Expand Down

0 comments on commit 78a172a

Please sign in to comment.