Skip to content

Commit

Permalink
Silently ignore incompatible cache file
Browse files Browse the repository at this point in the history
Rather than raising an error when a cache file is made for a greater
Modules version, ignore it silently.

This change helps to have different version of the Modules tool deployed
on the same site.

Fixes #515
  • Loading branch information
xdelaruelle committed Oct 5, 2023
1 parent 94be93f commit 3110682
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Modules 5.4.0 (not yet released)
:envvar:`__MODULES_LMSTICKYRULE` environment variable. It helps to determine
if stickiness is satisfied when changing loaded modules. Which was not
working correctly for virtual modules. (fix issue #506)
* Silently ignore cache file when it requires a greater Modules version. (fix
issue #515)


.. _5.3 release notes:
Expand Down
4 changes: 4 additions & 0 deletions doc/source/design/module-cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ file is used. They are primarily useful to skip I/O tests when walking through
the content of a modulepath directory. As these I/O tests are done during the
cache build process, the options are useless when using cache files.

When cache file magic cookie defines a Modules version greater than the
current one, the cache file is silently ignored. Raisin error is not useful as
different version of Modules may be deployed in the same site environment.

When cache file is not in sync
------------------------------

Expand Down
4 changes: 2 additions & 2 deletions tcl/cache.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ proc readCacheContent {cachefile} {
{Cache ERROR}
# check if min version requirement is met
} elseif {[versioncmp {@MODULES_RELEASE@} $fhvers] <0} {
reportInternalBug "Cache file requires at least Modules version\
$fhvers" $cachefile {Cache ERROR}
reportDebug "Cache file $cachefile requires at least Modules version\
$fhvers"
} else {
# set file content as result
set res $fdata
Expand Down
16 changes: 15 additions & 1 deletion testsuite/modules.30-cache/040-cache-use.exp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,21 @@ modulefile-content bar/1.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK $tserr_avail1
testouterr_cmd sh {avail -a -t -o foo} OK $tserr_avail2
testouterr_cmd sh {load bar} $ans_load1b [cacheerr_minverreq $mp1cache 99]
testouterr_cmd sh {load bar} $ans_load1 {}
file delete $mp1cache

# test with a module header with required version below current version
set fid [open $mp1cache w]
puts $fid "#%Module5.2
modulefile-content bar/1.0 1664035017 #%Module #%Module"
close $fid
testouterr_cmd sh {avail -a -t -o } OK bar/1.0
testouterr_cmd sh {avail -a -t -o foo} OK {}
set ans [list]
lappend ans [list set __MODULES_LMALTNAME bar/1.0&as|bar/default&as|bar/latest]
lappend ans [list set _LMFILES_ $mp1/bar/1.0]
lappend ans [list set LOADEDMODULES bar/1.0]
testouterr_cmd sh {load bar} $ans {}
file delete $mp1cache

# tests with a cache containing element that does not exists anymore in modulepath
Expand Down

0 comments on commit 3110682

Please sign in to comment.