Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error even with sticky_purge silent when dependent is sticky #536

Open
adrien-cotte opened this issue Aug 27, 2024 · 1 comment
Open

Error even with sticky_purge silent when dependent is sticky #536

adrien-cotte opened this issue Aug 27, 2024 · 1 comment
Labels
Milestone

Comments

@adrien-cotte
Copy link
Contributor

Describe the bug

While purging modules, error if a module has a sticky dependent.

To Reproduce

Steps to reproduce the behavior:

  1. Create 3 files:
  • modulefiles/dep/1.0
#%Module
  • modulefiles/main/1.0
#%Module
conflict main
prereq dep
  • modulefiles/.modulerc
#%Module
module-tag super-sticky main
module-tag super-sticky dep

(note: stickiness of dep does not have any effect for this bug)

  1. Load main module:
$ module load main
  1. Configure sticky_purge to silent:
$ module config sticky_purge silent
  1. Purge modules:
$ module purge
Unloading dep/1.0
  ERROR: Dependent main/1.0 is loaded
  1. Same with wticky_purge warning:
Unloading main/1.0
  WARNING: Unload of super-sticky module skipped

Unloading dep/1.0
  ERROR: Dependent main/1.0 is loaded

Expected behavior

When a dependent of a module is sticky and sticky_purge value isn't error, then module command should not returns an error.

Modules version and configuration

$ module --version
Modules Release 5.4.0 (2024-02-20)

Additional context

The following patch workarounds the problem but is not enough, there are still 2 problems:

  • duplicated message when sticky_purge is warning
$ module config sticky_purge warning
$ module load main
$ module purge
Unloading main/1.0
  WARNING: Unload of super-sticky module skipped

Unloading dep/1.0
  WARNING: Unload of super-sticky module skipped
  WARNING: Unload of super-sticky module skipped
  • get a warning message when purge is forced
$ module config sticky_purge silent
$ module load main
$ module purge -f
Unloading dep/1.0
  WARNING: Dependent main/1.0 is loaded
diff --git a/tcl/subcmd.tcl.in b/tcl/subcmd.tcl.in
index c83f6af0..1eebd310 100644
--- a/tcl/subcmd.tcl.in
+++ b/tcl/subcmd.tcl.in
@@ -1543,9 +1543,23 @@ proc cmdModuleUnload {context match auto force onlyureq args} {
                   reportWarning [getDepLoadedMsg $prereq_list]
                }
             } else {
-               knerror [expr {[isModuleEvaluated any $modnamevr {}\
-                  {*}$prereq_list] ? [getDepLoadedMsg $prereq_list] :\
-                  [getErrPrereqMsg $prereq_list 0]}]
+               # Initialize a flag to indicate if any dependent is sticky
+               set stickyFound 0
+               # Iterate over each module in the prereq_list
+               foreach dep $prereq_list {
+                   if {[skipUnloadIfSticky unload $dep $modfile]} {
+                       set stickyFound 1
+                       break
+                   }
+               }
+               # If any dependent is sticky, we prevent the unload
+               if {$stickyFound} {
+                   set ret 0
+               } else {
+                  knerror [expr {[isModuleEvaluated any $modnamevr\
+                     {*}$prereq_list] ? [getDepLoadedMsg $prereq_list] :\
+                     [getErrPrereqMsg $prereq_list 0]}]
+               }
             }
          }
@xdelaruelle xdelaruelle added this to the 5.5.0 milestone Aug 27, 2024
@xdelaruelle
Copy link
Member

Many thanks Adrien for your report.

After a quick analysis, I see that dependent are checked prior stickiness. Thus the dependent error is raised even if stickiness is set silent.

I will try to fix this by checking stickiness prior dependent modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants