From af494d5cca0f2274ab464f1ade35c12c7ea47208 Mon Sep 17 00:00:00 2001 From: Michal Hecko Date: Wed, 3 Jul 2024 23:39:46 +0200 Subject: [PATCH] snactor(run): allow using leapp's execution contexts 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. --- leapp/snactor/context.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/leapp/snactor/context.py b/leapp/snactor/context.py index d3ab66502..c6e3831ca 100644 --- a/leapp/snactor/context.py +++ b/leapp/snactor/context.py @@ -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= 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