Persist worker_name after job is finished (#1730)

* Persist worker_name after job is finished

Persisting the worker_name on the job object in Redis would allow for debugging and
analyzing logs from the worker

* Remove redundent job.save() method call

* Remove check for null worker

Now that worker name is persisted after job finishes or fails,
no need to assert that worker name is None

* Change github runner to Ubuntu 20.04

* Change github runner to Ubuntu 20.04
This commit is contained in:
eswolinsky3241 2022-11-25 22:37:27 -05:00 committed by GitHub
parent f39554dbe4
commit 5119716911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 5 additions and 10 deletions

View File

@ -7,7 +7,7 @@ on:
jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
# required for all workflows

View File

@ -10,7 +10,7 @@ jobs:
build:
if: github.repository == 'rq/rq'
name: Python${{ matrix.python-version }}/Redis${{ matrix.redis-version }}/redis-py${{ matrix.redis-py-version }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8.3", "3.9", "3.10"]

View File

@ -14,7 +14,7 @@ permissions:
jobs:
push:
if: github.repository == 'rq/rq'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

View File

@ -12,7 +12,7 @@ permissions:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

View File

@ -12,7 +12,7 @@ permissions:
jobs:
build:
name: Python${{ matrix.python-version }}/Redis${{ matrix.redis-version }}/redis-py${{ matrix.redis-py-version }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8.3", "3.9", "3.10"]

View File

@ -980,7 +980,6 @@ class Worker:
job_class=self.job_class,
serializer=self.serializer
)
job.worker_name = None
# check whether a job was stopped intentionally and set the job
# status appropriately if it was this job.
@ -1060,8 +1059,6 @@ class Worker:
if result_ttl != 0:
self.log.debug('Setting job %s status to finished', job.id)
job.set_status(JobStatus.FINISHED, pipeline=pipeline)
job.worker_name = None
# Result should be saved in job hash only if server
# doesn't support Redis streams
include_result = not self.supports_redis_streams
@ -1071,7 +1068,6 @@ class Worker:
if self.supports_redis_streams:
Result.create(job, Result.Type.SUCCESSFUL, return_value=job._result,
ttl=result_ttl, pipeline=pipeline)
finished_job_registry = queue.finished_job_registry
finished_job_registry.add(job, result_ttl, pipeline)

View File

@ -379,7 +379,6 @@ class TestWorker(RQTestCase):
# Check the job
job = Job.fetch(job.id)
self.assertEqual(job.origin, q.name)
self.assertIsNone(job.worker_name) # Worker name is cleared after failures
# Should be the original enqueued_at date, not the date of enqueueing
# to the failed queue