Skip to content

Commit

Permalink
snactor(run): allow using leapp's execution contexts
Browse files Browse the repository at this point in the history
Introduce the 'LEAPP_DEBUG_PRESERVE_CONTEXT' environmental variable.
When the variable is set to 1 and the environment has
'LEAPP_EXECUTION_ID' set, the 'LEAPP_EXECUTION_ID' is not overwritten
with snactor's execution ID. This allows the developer to run actors
in the same fashion as if the actor was run during the last leapp's
execution, thus, avoiding to rerun the entire upgrade process.
This, naturally, does not help when the actor has outside dependencies,
i.e., it requires the filesystem to be set up in a specific way (e.g.
a target container) must be present, e.t.c.
  • Loading branch information
Michal Hecko committed Jul 3, 2024
1 parent b57c5de commit e2a7c77
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion leapp/snactor/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def last_snactor_context(connection=None):
def with_snactor_context(f):
@command_aware_wraps(f)
def wrapper(*args, **kwargs):
os.environ["LEAPP_EXECUTION_ID"] = last_snactor_context()
# To preserve context, one needs to LEAPP_DEBUG_PRESERVE_CONTEXT=1 and have LEAPP_EXECUTION_ID=<id> set.
if not (os.environ.get('LEAPP_DEBUG_PRESERVE_CONTEXT', '0') == '1' and os.environ.get('LEAPP_EXECUTION_ID')):
os.environ["LEAPP_EXECUTION_ID"] = last_snactor_context()
return f(*args, **kwargs)
return wrapper

0 comments on commit e2a7c77

Please sign in to comment.