Repository navigation
Fix inconsistencies left by a failed module evaluation - #751
Merged
Merged
Conversation
Extra tags, enabled modulepaths and sourced shell scripts of loaded modules are recorded in memory structures that were not part of the settings pushed before an evaluation. When a module load fails, its evaluation is rolled back but these records are kept. If the same module is then successfully loaded, the properties saved for it in the loaded environment mix those of the failed attempt with those of the successful one. Save these structures along with the other settings, so a rollback restores them to their state prior the failed evaluation. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Result of the test checking that a loaded or loading module comes from a given modulepath is cached and this cache is only dropped when a module is unloaded. When the load of a module fails, the requirements it has loaded are withdrawn by a rollback and their cache entry is kept. If such requirement is then loaded from another modulepath, the outdated entry makes it satisfy a requirement targeting the first modulepath. Save these caches along with the other settings pushed before an evaluation, so a rollback restores them to their state prior the failed evaluation. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
The module modulefile command sets states describing the sub-command it runs: its name, the way modulefiles should be read and, when the --not-req option is set, the inhibition of requirement recording. These states were only withdrawn when the sub-command ended without error. When it raised an error, like for a module to load that cannot be found, the modulefile evaluation is aborted but these states stayed set for the modulefiles evaluated afterward. Among other effects, a module loaded with "module load --not-req" was kept loaded when the module that has loaded it got unloaded. Run the sub-command from a dedicated procedure, so the calling module procedure withdraws the states whatever the result obtained. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Modulepath restrictions set with the --modulepath option of prereq are recorded per module as a list of requirement and modulepath list pairs. New pairs were added to this list element by element, skipping those already found in it. A second requirement restricted to the same modulepath, or the same requirement defined again with another restriction, thus led to an unbalanced list and to an internal error when the dependencies of the loading module were computed. Record these restrictions pair by pair. When a requirement is defined several times, the modulepaths common to its definitions are retained, as a loaded module has to comply with all of them. Definitions without any modulepath in common can never be fulfilled and make the load fail. Latest definition is recorded in this case, so the requirement is reported unmet if load is forced. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
When conflict_unload option is enabled, a requirement loaded from another modulepath than the one expected is unloaded and replaced instead of making the load fail. Assisted-by: Claude:claude-fable-5-2 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up of #750: other in-memory structures were not restored when a module evaluation fails and gets rolled back, leading to inconsistent results for the modules evaluated afterward by the same command.
module use) and sourced shell scripts (source-sh) of loaded modules are now saved along with the other settings pushed before an evaluation. Previously, when a module load failed then the same module was successfully loaded,__MODULES_LMEXTRATAG,__MODULES_LMUSEand__MODULES_LMSOURCESHmixed the properties of the failed attempt with those of the successful one.prereq --modulepathtargeting the first modulepath.modulemodulefile command now withdraws the states it sets (sub-command name, modulefile read mode, requirement record inhibition) even if the sub-command it runs raises an error. These states were kept for the modulefiles evaluated afterward: for instance a module loaded withmodule load --not-reqwas kept loaded when the module that has loaded it got unloaded.A last commit fixes an issue found while testing the above, which is not related to failed evaluations: an internal error (
list must have an even number of elements) was raised when loading a modulefile that defines several requirements restricted to the same modulepath withprereq --modulepath, or that defines the same requirement several times with different modulepath restrictions. These restrictions were recorded element by element instead of pair by pair. When a requirement is defined several times, the modulepaths common to its definitions are now retained. This issue exists since the record of these restrictions was introduced in 5.5.0.Each fix comes with tests, added to
377-rollback.expand to the new642-modulepath-multi.exptestsuite file.