Thanks to visit codestin.com
Credit goes to github.com

Skip to content

module reload/refresh fails when cycles exist in modulefiles #433

@ben-bowers

Description

@ben-bowers

Describe the bug

If modulefiles contain a "cycle" where one modulefile prereqs another modulefile that also does a prereq, a cycle is created and cannot be resolved by either reload or refresh. A standard module load does not apparently have an issue with breaking the circular dependency.

Why would one wish to have a cycle? In the case where some modulefile may want to load settings from another modulefile, but it is uncertain which modulefile the user would load. For example if doing module load AB, then also prereq file BA. If doing module load BA, then also prereq file AB.

To Reproduce

Steps to reproduce the behavior:

$ module load BA
Loading BA
  Loading requirement: AB

$ module refresh
ERROR: Cannot reload modules, some of their constraints are not satistied

$ module reload
ERROR: Cannot reload modules, some of their constraints are not satistied

Location and content of any modulerc or modulefile involved:

$ cat AB
#%Module1.0 # -*- tcl -*-
prereq BA
setenv AA aa

$ cat BA
#%Module1.0 # -*- tcl -*-
prereq AB
setenv BB bb

Expected behavior

Ideally both reload and refresh could break the cycle and not fail to execute. I do not understand the internals of modules (or what breadcrumbs are saved in the environment) well enough to know if this is possible.

If this is not possible, is there a suggested workaround for this limitation?

Error and debugging information

Using debug mode enough output is printed to help me diagnose that some cycle was found, which presumably is the root issue.

$ module reload -D
...
DEBUG runModulerc: running...
DEBUG cmdModuleReload: reloading BA AB
DEBUG getUnloadMatchOrder: unload_match_order set to 'returnlast'
DEBUG setModuleDependency: set an unmet requirement on 'AB' for 'BA'
DEBUG setModuleDependency: set prereq violation state for 'BA'
DEBUG doesModuleConflict: 'BA' conflicts with '' (declared as '')
DEBUG setModuleDependency: set requirements of 'BA' to ''
DEBUG setModuleDependency: set NPO requirements of 'BA' to 'AB'
DEBUG doesModuleConflict: 'AB' conflicts with '' (declared as '')
DEBUG setModuleDependency: refresh requirements targetting 'AB'
DEBUG getDependentLoadedModuleList: get loaded mod dependent of 'BA' (strong=0, direct=0, nporeq=0, loading=1, sat_constraint=0, being_unload=0)
DEBUG getDependentLoadedModuleList: got 'AB'
DEBUG setModuleDependency: skip deps refresh for 'BA' as dep cycle detected with 'AB'
DEBUG setModuleDependency: update NPO dependent of 'AB' to ''
DEBUG setModuleDependency: set NPO prereq violation state for 'BA'
DEBUG setModuleDependency: update NPO requirement of 'BA' to '{}'
DEBUG setModuleDependency: set requirements of 'AB' to 'BA'
DEBUG setModuleDependency: set NPO requirements of 'AB' to 'BA'
DEBUG cacheCurrentModules: 2 loaded
ERROR: Cannot reload modules, some of their constraints are not satistied
DEBUG renderSettings: called.
DEBUG renderSettings: 1 error(s) detected.
DEBUG renderFalse: called.

Modules version and configuration

$ module --version
Modules Release 4.3.1 (2019-09-21)

$ module config --dump-state
...
MODULES_AUTO_HANDLING     1
...

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions