Skip to content
Snippets Groups Projects
Commit 5c572f0b authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Update rq and rq-dashboard

- REDIS_URL is deprecated by rq-dashboard. Set RQ_DASHBOARD_REDIS_URL.
- Change REDIS_URL to RQ_REDIS_URL.
- Add favicon.ico under static directory as it's required by
  rq-dashboard...

JIRA INFRA-2649
parent e30e059b
No related branches found
No related tags found
No related merge requests found
......@@ -139,7 +139,7 @@ def register_cli(app):
@app.cli.command()
def runworker():
"""Run RQ worker"""
redis_url = current_app.config["REDIS_URL"]
redis_url = current_app.config["RQ_REDIS_URL"]
redis_connection = redis.from_url(redis_url)
with rq.Connection(redis_connection):
worker = TaskWorker(["high", "normal", "low"])
......
......@@ -81,7 +81,7 @@ def modified_static_file(endpoint, values):
def get_redis_connection():
redis_connection = getattr(g, "_redis_connection", None)
if redis_connection is None:
redis_url = current_app.config["REDIS_URL"]
redis_url = current_app.config["RQ_REDIS_URL"]
redis_connection = g._redis_connection = redis.from_url(redis_url)
return redis_connection
......
......@@ -32,7 +32,8 @@ SESSION_TYPE = "redis"
SESSION_REDIS_URL = "redis://redis:6379/0"
CACHE_TYPE = "redis"
CACHE_REDIS_URL = "redis://redis:6379/1"
REDIS_URL = "redis://redis:6379/2"
RQ_REDIS_URL = "redis://redis:6379/2"
RQ_DASHBOARD_REDIS_URL = RQ_REDIS_URL
ELASTICSEARCH_URL = "http://elasticsearch:9200"
ELASTICSEARCH_INDEX_SUFFIX = "-dev"
......
app/static/favicon.ico

14.7 KiB

......@@ -10,7 +10,6 @@ This module implements tasks to run.
"""
import time
import traceback
import tower_cli
from datetime import datetime
from flask import current_app
......@@ -26,18 +25,19 @@ class TaskWorker(Worker):
the task status and end time in the CSEntry database
"""
def save_exception(self, job, *exc_info):
@staticmethod
def save_exception(job, exc_string):
"""Save the exception to the database
The exception is only saved if it occured before the AWX job was triggered.
If the AWX job failed, we can refer to the logs on AWX.
"""
task = models.Task.query.get(job.id)
if task is None:
return
if task.awx_job_id is None:
# No AWX job was triggered. An exception occured before. Save it.
task.exception = self._get_safe_exception_string(
traceback.format_exception(*exc_info)
)
task.exception = exc_string
db.session.commit()
def update_task_attributes(self, job, attributes):
......@@ -62,23 +62,23 @@ class TaskWorker(Worker):
setattr(task, name, value)
db.session.commit()
def update_reverse_dependencies(self, job):
@staticmethod
def update_reverse_dependencies(job):
task = models.Task.query.get(job.id)
if task is None:
return
task.update_reverse_dependencies()
db.session.commit()
def move_to_failed_queue(self, job, *exc_info):
# This could be achieved by passing a custom exception handler
# when initializing the worker. As we already subclass it, it's
# easier to override the default handler in case of failure
def handle_job_failure(self, job, queue, started_job_registry=None, exc_string=""):
self.update_task_attributes(
job, {"ended_at": job.ended_at, "status": models.JobStatus.FAILED}
)
self.update_reverse_dependencies(job)
self.save_exception(job, *exc_info)
super().move_to_failed_queue(job, *exc_info)
self.save_exception(job, exc_string)
super().handle_job_failure(
job, queue, started_job_registry=started_job_registry, exc_string=exc_string
)
def handle_job_success(self, job, queue, started_job_registry):
self.update_task_attributes(
......@@ -86,9 +86,9 @@ class TaskWorker(Worker):
)
super().handle_job_success(job, queue, started_job_registry)
def prepare_job_execution(self, job):
def prepare_job_execution(self, job, heartbeat_ttl=None):
self.update_task_attributes(job, {"status": models.JobStatus.STARTED})
super().prepare_job_execution(job)
super().prepare_job_execution(job, heartbeat_ttl)
def launch_awx_job(resource="job", **kwargs):
......
......@@ -20,8 +20,8 @@ pyyaml
qrcode
whitenoise
ansible-tower-cli<3.3.9
rq<1.0
rq-dashboard<0.5.0
rq
rq-dashboard
sentry-sdk
sqlalchemy<1.3
sqlalchemy-citext
......
......@@ -40,8 +40,8 @@ PyYAML==5.3.1
qrcode==6.1
redis==3.5.3
requests==2.24.0
rq==0.13.0
rq-dashboard==0.4.0
rq==1.5.2
rq-dashboard==0.6.1
sentry-sdk==0.19.1
six==1.15.0
SQLAlchemy==1.2.19
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment