From 95a64f0edaa8077d68375c3ca363b9e28541bc4e Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 21 Aug 2022 14:29:20 +0200 Subject: [PATCH] Allow unload of sticky modules on restore sub-cmd Allow the unload of sticky modules when restoring collection. Goal is to be able to restore designated collection as it was saved, thus without the loaded sticky modules. If such collections were saved without the sticky modules in it, it means that these sticky modules can safely be unloaded when moving to the collection state. As a result, using the --force option is of no use for restore sub-command. This change does not impact super-sticky modules. Such modules cannot be unloaded during a restore, even if forced. With this change, behavior of restore sub-command with sticky modules is aligned with Lmod. --- tcl/mfinterp.tcl.in | 3 ++- tcl/subcmd.tcl.in | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tcl/mfinterp.tcl.in b/tcl/mfinterp.tcl.in index e8c26f68..dccaa7d8 100644 --- a/tcl/mfinterp.tcl.in +++ b/tcl/mfinterp.tcl.in @@ -219,7 +219,8 @@ proc execute-modulefile {modfile modname modnamevrvar modspec {up_namevr 1}\ lpopState modulefile knerror [getStickyUnloadMsg super-sticky] } elseif {[isModuleTagged $modname sticky 1] && [currentState\ - reloading_sticky] ne $modname} { + reloading_sticky] ne $modname && [currentState unloading_sticky] ne\ + $modname} { if {[getState force]} { reportWarning [getStickyForcedUnloadMsg] } else { diff --git a/tcl/subcmd.tcl.in b/tcl/subcmd.tcl.in index aa5a9048..65d34d32 100644 --- a/tcl/subcmd.tcl.in +++ b/tcl/subcmd.tcl.in @@ -647,17 +647,14 @@ proc cmdModuleRestore {args} { } else { set modvr $mod } - if {[set sticky_reload [isStickinessReloading $modvr $mod_to_load]]} { - lappendState reloading_sticky $mod - } + # sticky modules can be unloaded when restoring collection + lappendState unloading_sticky $mod if {[set supersticky_reload [isStickinessReloading $modvr $mod_to_load\ super-sticky]]} { lappendState reloading_supersticky $mod } cmdModuleUnload unload match 0 0 0 0 $mod - if {$sticky_reload} { - lpopState reloading_sticky - } + lpopState unloading_sticky if {$supersticky_reload} { lpopState reloading_supersticky }