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.
This commit is contained in:
Xavier Delaruelle
2022-08-21 14:29:20 +02:00
parent b962935a10
commit 95a64f0eda
2 changed files with 5 additions and 7 deletions

View File

@@ -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 {

View File

@@ -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
}