diff --git a/reana_job_controller/config.py b/reana_job_controller/config.py index 93d3a698..e1bc02bb 100644 --- a/reana_job_controller/config.py +++ b/reana_job_controller/config.py @@ -14,6 +14,9 @@ from werkzeug.utils import import_string +CACHE_ENABLED = False +"""Determines if jobs caching is enabled.""" + SHARED_VOLUME_PATH_ROOT = os.getenv("SHARED_VOLUME_PATH_ROOT", "/var/reana") """Root path of the shared volume .""" diff --git a/reana_job_controller/job_manager.py b/reana_job_controller/job_manager.py index b4236aee..7bb1583f 100644 --- a/reana_job_controller/job_manager.py +++ b/reana_job_controller/job_manager.py @@ -15,6 +15,8 @@ from reana_db.models import Job as JobTable from reana_db.models import JobCache, JobStatus, Workflow +from reana_job_controller.config import CACHE_ENABLED + class JobManager: """Job management interface.""" @@ -61,7 +63,8 @@ def wrapper(inst, *args, **kwargs): inst.before_execution() backend_job_id = fn(inst, *args, **kwargs) inst.create_job_in_db(backend_job_id) - inst.cache_job() + if CACHE_ENABLED: + inst.cache_job() db_engine.dispose() return backend_job_id diff --git a/tests/test_job_manager.py b/tests/test_job_manager.py index 10a5c14e..e3611b9e 100644 --- a/tests/test_job_manager.py +++ b/tests/test_job_manager.py @@ -131,6 +131,7 @@ def test_stop_kubernetes_job( kubernetes_client.delete_namespaced_job.assert_called_once() +@mock.patch("reana_job_controller.job_manager.CACHE_ENABLED", True) def test_execution_hooks(): """Test hook execution order."""