diff --git a/internal/controllers/nmc_reconciler.go b/internal/controllers/nmc_reconciler.go index 88f051baa..dcf8bb868 100644 --- a/internal/controllers/nmc_reconciler.go +++ b/internal/controllers/nmc_reconciler.go @@ -408,8 +408,10 @@ func (h *nmcReconcilerHelperImpl) ProcessUnconfiguredModuleStatus( it also fixes the scenario when node's kernel was upgraded, so unload pod will fail anyway */ if h.nodeAPI.NodeBecomeReadyAfter(node, status.LastTransitionTime) { - logger.Info("node was rebooted, no need to unload kernel module that is not present in kernel, will wait until NMC spec is updated") - return nil + logger.Info("node was rebooted and spec is missing: delete the status to allow Module CR unload, if needed") + patchFrom := client.MergeFrom(nmcObj.DeepCopy()) + nmc.RemoveModuleStatus(&nmcObj.Status.Modules, status.Namespace, status.Name) + return h.client.Status().Patch(ctx, nmcObj, patchFrom) } pod, err := h.pm.GetWorkerPod(ctx, podName, status.Namespace) diff --git a/internal/controllers/nmc_reconciler_test.go b/internal/controllers/nmc_reconciler_test.go index d6cd8c7e9..08499b686 100644 --- a/internal/controllers/nmc_reconciler_test.go +++ b/internal/controllers/nmc_reconciler_test.go @@ -793,6 +793,8 @@ var _ = Describe("nmcReconcilerHelperImpl_ProcessUnconfiguredModuleStatus", func podName = workerPodName(nmcName, name) client *testclient.MockClient + sw *testclient.MockStatusWriter + pm *MockpodManager nm *node.MockNode helper nmcReconcilerHelper @@ -801,6 +803,7 @@ var _ = Describe("nmcReconcilerHelperImpl_ProcessUnconfiguredModuleStatus", func BeforeEach(func() { ctrl := gomock.NewController(GinkgoT()) client = testclient.NewMockClient(ctrl) + sw = testclient.NewMockStatusWriter(ctrl) pm = NewMockpodManager(ctrl) nm = node.NewMockNode(ctrl) helper = newNMCReconcilerHelper(client, pm, nil, nm) @@ -820,7 +823,11 @@ var _ = Describe("nmcReconcilerHelperImpl_ProcessUnconfiguredModuleStatus", func node := v1.Node{} It("should do nothing , if the node has been rebooted/ready lately", func() { - nm.EXPECT().NodeBecomeReadyAfter(&node, status.LastTransitionTime).Return(true) + gomock.InOrder( + nm.EXPECT().NodeBecomeReadyAfter(&node, status.LastTransitionTime).Return(true), + client.EXPECT().Status().Return(sw), + sw.EXPECT().Patch(ctx, nmc, gomock.Any()), + ) Expect( helper.ProcessUnconfiguredModuleStatus(ctx, nmc, status, &node),