From 960266b1c6df02d1d0aaeb97c156dadaaec31cd3 Mon Sep 17 00:00:00 2001 From: Yuvarani Shankar Date: Mon, 6 Jul 2026 18:53:57 -0700 Subject: [PATCH] fix: remove ionic from modulesLoadingOrder to fix soft-dep unload (NETOP-180) (#343) ionic is a hard kernel dependency of ionic_rdma (tracked by depmod) and should not be in modulesLoadingOrder. Including it in the softdep chain prevents modprobe -r from cascading the unload to pds_core and tawk_ipc when the Module CR is deleted. With ionic removed, the modulesLoadingOrder only contains soft dependencies: [ionic_rdma, pds_core, tawk_ipc]. KMM generates a softdep.conf that modprobe -r can follow to unload all three, while ionic is unloaded automatically via the kernel dependency chain. Co-authored-by: Yuva Shankar <11082310+yuva29@users.noreply.github.com> Co-authored-by: Claude Opus 4 (1M context) (cherry picked from commit 2573db5d9c365b66624dc3a02dda7b3bad504f93) --- internal/kmmmodule/kmmmodule.go | 17 +++++++++-------- internal/kmmmodule/kmmmodule_test.go | 2 -- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/kmmmodule/kmmmodule.go b/internal/kmmmodule/kmmmodule.go index df04f657..bd9f71a6 100644 --- a/internal/kmmmodule/kmmmodule.go +++ b/internal/kmmmodule/kmmmodule.go @@ -273,9 +273,11 @@ func (km *kmmModule) setKMMModuleLoader(ctx context.Context, mod *kmmv1beta1.Mod } // Use ionic_rdma as the main module (topmost module in the dependency chain) - // KMM's modulesLoadingOrder expects: [topmost module, then what it depends on, etc.] - // Dependency chain: ionic_rdma -> ionic -> pds_core -> tawk_ipc - // For unloading, KMM will reverse this order automatically + // KMM's modulesLoadingOrder expects: [topmost module, then soft deps it needs] + // ionic is a hard kernel dependency of ionic_rdma (handled by depmod/modprobe + // automatically) and must NOT be in modulesLoadingOrder — including it prevents + // KMM from unloading pds_core and tawk_ipc via the softdep reverse chain. + // Only soft dependencies (not tracked by depmod) belong in this list. moduleName := networkDriverModuleName var modulesLoadingOrder []string @@ -289,13 +291,12 @@ func (km *kmmModule) setKMMModuleLoader(ctx context.Context, mod *kmmv1beta1.Mod modulesLoadingOrder = mod.Spec.ModuleLoader.Container.Modprobe.ModulesLoadingOrder kmlog.Info(fmt.Sprintf("Preserving existing modulesLoadingOrder for upgrade: %v", modulesLoadingOrder)) } else { - // New installation: use correct module loading order - // ionic_rdma is the topmost module, followed by its dependencies + // New installation: only list soft dependencies that depmod doesn't know about. + // ionic is omitted because it is a hard kernel dependency of ionic_rdma. modulesLoadingOrder = []string{ networkDriverModuleName, // ionic_rdma (topmost module) - ionicModuleName, // ionic (ionic_rdma depends on this) - pdsCoreModuleName, // pds_core (ionic depends on this) - tawkIPCModuleName, // tawk_ipc (pds_core depends on this) + pdsCoreModuleName, // pds_core (soft dep) + tawkIPCModuleName, // tawk_ipc (soft dep) } kmlog.Info(fmt.Sprintf("Using new modulesLoadingOrder for fresh installation: %v", modulesLoadingOrder)) } diff --git a/internal/kmmmodule/kmmmodule_test.go b/internal/kmmmodule/kmmmodule_test.go index c1301155..110937cb 100644 --- a/internal/kmmmodule/kmmmodule_test.go +++ b/internal/kmmmodule/kmmmodule_test.go @@ -331,7 +331,6 @@ var _ = PDescribe("setKMMModuleLoader", func() { expectedMod.Spec.ModuleLoader.Container.Modprobe.ModuleName = networkDriverModuleName expectedMod.Spec.ModuleLoader.Container.Modprobe.ModulesLoadingOrder = []string{ networkDriverModuleName, - ionicModuleName, pdsCoreModuleName, tawkIPCModuleName, } @@ -410,7 +409,6 @@ var _ = PDescribe("setKMMModuleLoader", func() { expectedMod.Spec.ModuleLoader.Container.Modprobe.ModuleName = networkDriverModuleName expectedMod.Spec.ModuleLoader.Container.Modprobe.ModulesLoadingOrder = []string{ networkDriverModuleName, - ionicModuleName, pdsCoreModuleName, tawkIPCModuleName, }