From ffcce36829cd6138713ea61a4c834a18b392e2ff Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Fri, 14 Jun 2019 13:37:44 +0200 Subject: [PATCH] Add setting to configure RQ default timeout Default timeout increased to 30 minutes. Some AWX tasks can be quite long especially as the csentry inventory update can't run at the same time as other jobs. JIRA INFRA-1051 --- app/models.py | 2 +- app/settings.py | 2 ++ app/utils.py | 5 ----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/models.py b/app/models.py index 1d23a02..e7bce66 100644 --- a/app/models.py +++ b/app/models.py @@ -347,7 +347,7 @@ class User(db.Model, UserMixin): The task is added to the session but not committed. """ - q = Queue(queue_name) + q = Queue(queue_name, default_timeout=current_app.config["RQ_DEFAULT_TIMEOUT"]) job = q.enqueue(f"app.tasks.{func}", **kwargs) # The status will be set to QUEUED or DEFERRED task = Task( diff --git a/app/settings.py b/app/settings.py index b7e0c43..625938e 100644 --- a/app/settings.py +++ b/app/settings.py @@ -146,3 +146,5 @@ SENTRY_DSN = os.environ.get("SENTRY_DSN", "") # Static local files CSENTRY_STATIC_DIR = Path(__file__).parent / "static" CSENTRY_STATIC_FILES = CSENTRY_STATIC_DIR / "files" + +RQ_DEFAULT_TIMEOUT = 1800 diff --git a/app/utils.py b/app/utils.py index 3fa9bbf..b1b120d 100644 --- a/app/utils.py +++ b/app/utils.py @@ -258,7 +258,6 @@ def trigger_core_services_update(): "job_template": job_template, "resource": resource, "depends_on": inventory_task.id, - "timeout": 500, } current_app.logger.info(f"Launch new job to update core services: {job_template}") task = current_user.launch_task( @@ -350,7 +349,6 @@ def trigger_vm_creation( func="launch_awx_job", job_template=job_template, extra_vars=extra_vars, - timeout=500, ) if ( post_job_template @@ -365,7 +363,6 @@ def trigger_vm_creation( job_template=post_job_template, limit=f"{host.fqdn}", depends_on=task.id, - timeout=500, ) current_app.logger.info( f"Trigger post install job: run {post_job_template} on {host.fqdn}" @@ -395,7 +392,6 @@ def trigger_ztp_configuration(host): func="launch_awx_job", job_template=job_template, extra_vars=extra_vars, - timeout=500, ) return task @@ -417,7 +413,6 @@ def trigger_set_network_boot_profile(host, boot_profile): func="launch_awx_job", job_template=job_template, extra_vars=extra_vars, - timeout=500, ) return task -- GitLab