| 1 |
.. _conflict-unload: |
| 2 |
|
| 3 |
Conflict unload |
| 4 |
=============== |
| 5 |
|
| 6 |
This document described the Conflict Unload mechanism (ConUn) part of the |
| 7 |
automated module handling mechanisms. Conflict Unload goals are to remove |
| 8 |
conflicting modules when loading a new one. |
| 9 |
|
| 10 |
``conflict_unload`` configuration option |
| 11 |
---------------------------------------- |
| 12 |
|
| 13 |
A new configuration option :mconfig:`conflict_unload` is introduced as |
| 14 |
Conflict Unload introduces a new behavior. :mconfig:`auto_handling` option |
| 15 |
should also be enabled to activate Conflict Unload. |
| 16 |
|
| 17 |
``conflict_unload`` option is disabled by default not to change by default the |
| 18 |
current behavior, as this option is introduced on a feature release (not a |
| 19 |
major release). |
| 20 |
|
| 21 |
``conflict_unload`` option will be removed and behavior merged into |
| 22 |
``auto_handling`` option at next major version change (v6). |
| 23 |
|
| 24 |
New behavior |
| 25 |
------------ |
| 26 |
|
| 27 |
When a module is loading, Conflict Unload mechanism unloads all loaded modules |
| 28 |
conflicting with the new module to load or the modules it requires. Goal is to |
| 29 |
satisfy the last module load request (i.e., produce an environment that |
| 30 |
satisfy this request). |
| 31 |
|
| 32 |
As a result, a module load triggering a Conflict Unload mechanism may as a |
| 33 |
consequence also trigger Dependent Reload, Dependent Unload and Useless |
| 34 |
Requirement Unload mechanisms. These last 2 mechanisms were not triggered by |
| 35 |
a top load action prior that (only on a top unload or switch actions). DepUn |
| 36 |
and DepRe mechanisms are triggered either by the top level module to load or |
| 37 |
the modules it requires. UReqUn mechanism is only triggered by the top level |
| 38 |
module to load. |
| 39 |
|
| 40 |
*FUTURE*: another approach would be to satisfy the load request without |
| 41 |
changing the environment asked up to now. So auto-loaded modules may be |
| 42 |
changed, as well as modules asked by they generic name (e.g., *name*, not |
| 43 |
their fully qualified name (e.g., *name/version*). This approach may be |
| 44 |
developed in the future and a specific configuration option is be needed to |
| 45 |
define the expected Conflict Unload approach. |
| 46 |
|
| 47 |
Behavior examples |
| 48 |
----------------- |
| 49 |
|
| 50 |
The following modules are loaded and form a dependency chain. Each module |
| 51 |
declares a reflexive conflict:: |
| 52 |
|
| 53 |
A1 > B1 > C1 |
| 54 |
|
| 55 |
After a ``module load B2``: |
| 56 |
|
| 57 |
* Loaded environment should be ``A2 > B2 > C1`` |
| 58 |
* C1 should be unloaded by Dependent Reload mechanism |
| 59 |
* B1 should be unloaded by Conflict Unload mechanism |
| 60 |
* A1 should be unloaded by Conflict Unload mechanism |
| 61 |
* A2 should be loaded by Requirement Load |
| 62 |
* B2 is then loaded |
| 63 |
* C1 is then reloaded again |
| 64 |
|
| 65 |
After a ``module load C2``: |
| 66 |
|
| 67 |
* Loaded environment should be ``A2 > B2 > C2`` |
| 68 |
* C1 should be unloaded by Conflict Unload mechanism |
| 69 |
* B1 and A1 should be unloaded by Conflict Unload |
| 70 |
* A2 and B2 be loaded by Requirement Load |
| 71 |
* C2 is then loaded |
| 72 |
|
| 73 |
Conflict kinds |
| 74 |
-------------- |
| 75 |
|
| 76 |
Conflict Unload mechanism targets the 3 different conflict situations: |
| 77 |
|
| 78 |
* Conflicts declared by loaded modules against loading modules |
| 79 |
* Conflicts declared by loading modules against loaded modules (through |
| 80 |
``conflict`` or ``module unload/switch`` modulefile commands) |
| 81 |
* Loading module is already loaded but with a different set of variants |
| 82 |
* Loading module is already loaded but from a different modulepath than those |
| 83 |
asked by current load |
| 84 |
|
| 85 |
Loading modules here apply to asked module and the modules it requires. |
| 86 |
|
| 87 |
Implementation |
| 88 |
-------------- |
| 89 |
|
| 90 |
Current implementation is to apply Conflict Unload mechanism either on loading |
| 91 |
top module or the modules it requires. Subsequent mechanisms produced by ConUn |
| 92 |
(DepRe and DepUn) are thus also produced on each loading module (top or |
| 93 |
requirements). Produces where they occur and not globally scheduled. UReqUn is |
| 94 |
globally scheduled on top evaluation. |
| 95 |
|
| 96 |
Such implementation is less optimized than resolving every requirements and |
| 97 |
conflicts information to get expected loaded modules in a minimum number of |
| 98 |
evaluations. |
| 99 |
|
| 100 |
When loading a module, prior evaluating it, if a conflict is declared against |
| 101 |
it (or this module is already loaded with an alternative variant set or from |
| 102 |
an alternative modulepath than the one asked) by one or more: |
| 103 |
|
| 104 |
* loaded modules, unload this or these modules. This or these unloads may |
| 105 |
trigger either DepRe and DepUn mechanisms. |
| 106 |
* loading modules, raise an error as requested environment cannot be satisfied |
| 107 |
|
| 108 |
When evaluating a loading modulefile (either asked module or its |
| 109 |
requirements) and this module defines a conflict: |
| 110 |
|
| 111 |
* if one or more loaded modules match this conflict, unload them (and trigger |
| 112 |
DepRe and DepUn mechanisms if needed) |
| 113 |
* if one or more loading modules match this conflict, raise an error as |
| 114 |
requested environment cannot be satisfied |
| 115 |
|
| 116 |
Unload of multiple conflicting modules is achieved in the reversed loaded |
| 117 |
order (last loaded is unloaded first). |
| 118 |
|
| 119 |
DepUn modules of ConUn modules are transformed into DepRe modules. An attempt |
| 120 |
to reload them is performed at the end. |
| 121 |
|
| 122 |
UReqUn modules is scheduled after main load action, thus only from the top |
| 123 |
context. At this point all auto-loaded requirements of ConUn modules can be |
| 124 |
found and set as UReqUn modules to unload. |
| 125 |
|
| 126 |
Adaptation of automated module handling mechanisms |
| 127 |
-------------------------------------------------- |
| 128 |
|
| 129 |
Introduction of *Conflict Unload* mechanism requires to adapt some of the |
| 130 |
other automated module handling mechanisms. It is also a good opportunity to |
| 131 |
improve these mechanisms. |
| 132 |
|
| 133 |
Useless Requirement Unload |
| 134 |
^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 135 |
|
| 136 |
Changes made to the UReqUn mechanism: |
| 137 |
|
| 138 |
* UReqUn module list is computed after main module action |
| 139 |
* UReqUn mechanism is only triggered on top level evaluation |
| 140 |
|
| 141 |
* Avoid to trigger the unload of modules that may be ReqLo in the remaining |
| 142 |
parts of the process |
| 143 |
* As a consequence some modules are considered ConUn modules instead of |
| 144 |
UReqUn modules |
| 145 |
|
| 146 |
|
| 147 |
* UReqUn is introduced on load evaluation (to unload useless requirements |
| 148 |
coming from unload of ConUn modules) |
| 149 |
* For switch evaluation, UReqUn is moved from end of switch-unload phase to |
| 150 |
end of overall switch action (before DepRe reload phase) |
| 151 |
|
| 152 |
* As a consequence, some UReqUn modules may be considered ConUn modules of |
| 153 |
switched-on module. |
| 154 |
* It advocates for enabling ``conflict_unload`` option otherwise an error |
| 155 |
would be obtained on such situation (which was not the case previously |
| 156 |
as UReqUn process occurred at the end of switch unload phase) |
| 157 |
|
| 158 |
* DepRe modules that also are UReqUn modules are unloaded during DepRe unload |
| 159 |
phase, rather extracted from DepRe to be processed during UReqUn. These |
| 160 |
modules are reported as UReqUn modules to users (as they are not reloaded) |
| 161 |
* DepRe modules also identified as UReqUn modules, may not be a dependency of |
| 162 |
an unloaded module (like the other UReqUn modules). |
| 163 |
|
| 164 |
Dependent Reload |
| 165 |
^^^^^^^^^^^^^^^^ |
| 166 |
|
| 167 |
Changes made to the DepRe mechanism: |
| 168 |
|
| 169 |
* DepRe modules coming from UReqUn modules (i.e., modules in conflict with |
| 170 |
UReqUn modules) are computed when computing UReqUn module list and their |
| 171 |
DepRe unload phase is made right before UReqUn module unload, thus apart |
| 172 |
from the other DepRe modules |
| 173 |
|
| 174 |
* As a consequence these DepRe modules may not be reloaded in the same order |
| 175 |
compared to the other DepRe modules |
| 176 |
|
| 177 |
* Unload phase of DepRe modules is mixed with unload of DepUn modules in order |
| 178 |
to perform these unload in the reverse load order (to ensure a module is |
| 179 |
unloaded before its requirements) |
| 180 |
|
| 181 |
* Reload of DepRe module is attempted only it is loadable. Which means its |
| 182 |
requirements are loaded and it does not conflict with current loaded |
| 183 |
environment. If module is sticky (super-sticky or sticky and not forced) |
| 184 |
attempt to load DepRe module is performed even if not loadable. If force |
| 185 |
mode is enabled reload of non-loadable DepRe module is not attempted, unless |
| 186 |
if tagged super-sticky. Not reloaded DepRe module is considered as a DepUn |
| 187 |
module. |
| 188 |
|
| 189 |
* All reloads of DepRe modules are now performed on top load, unload or switch |
| 190 |
evaluation rather right after the load, unload or switch that triggers the |
| 191 |
unload phase of the DepRe mechanism. As a consequence, all Dependent Reload |
| 192 |
modules are reloaded after main module evaluation. |
| 193 |
|
| 194 |
Notes |
| 195 |
----- |
| 196 |
|
| 197 |
* A DepUn module of a ConUn module, may be a ReqLo of loading module |
| 198 |
|
| 199 |
* Depending on the order of declaration of the requirement and conflict, a |
| 200 |
different kind of error is obtained. |
| 201 |
* If requirement is defined prior conflict, ReqLo will seem satisfied when |
| 202 |
executing the prereq or module load command, but an attempt to unload it |
| 203 |
will occur afterward. |
| 204 |
|
| 205 |
* A DepRe module of a ConUn module, may also be a ReqLo of loading module |
| 206 |
|
| 207 |
* DepRe is unloaded locally by the ConUn evaluation but reloaded at the end |
| 208 |
of the overall evaluation. It if is also a ReqLo, it will be reloaded when |
| 209 |
the ReqLo is expressed, instead of being reloaded at the very end. |
| 210 |
* When DepRe is reloaded as ReqLo, it currently looses its extra tags and |
| 211 |
gets the auto-loaded tag applied. |
| 212 |
|
| 213 |
.. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: |