Skip to content

Custom scripts with job_timeout more than RQ_DEFAULT_TIMEOUT failed when rescheduled #17759

Closed
@miaow2

Description

@miaow2

Deployment Type

Self-hosted

Triage priority

I volunteer to perform this work (if approved)

NetBox Version

v4.1.3

Python Version

3.12

Steps to Reproduce

  1. Create script with job_timeout more than RQ_DEFAULT_TIMEOUT, for example, the default timeout is 300 secs, setting job_timeout to 500 and inside script only sleep for 400 secs
from time import sleep

from extras.scripts import Script


class TestScript(Script):
    class Meta:
        job_timeout = 500

    def run(self, data, commit):
        sleep(400)
  1. Run script with interval, for example 3 minutes

Expected Behavior

Script runs successfully and all scheduled after scripts are successful too

Observed Behavior

First running will be successful, but after that all scheduled jobs will fail with JobTimeoutException

[DJANGO] ERROR 2024-10-15 11:45:28,255 scripts 160778 140373397688448 An exception occurred: `JobTimeoutException: Task exceeded maximum timeout value (300 seconds)`

Traceback (most recent call last):
  File "/home/miaow/work/netbox/netbox/extras/jobs.py", line 45, in run_script
    script.output = script.run(data, commit)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miaow/work/netbox/netbox/scripts/test_script.py", line 11, in run
    sleep(400)
  File "/home/miaow/work/netbox/venv/lib/python3.12/site-packages/rq/timeouts.py", line 63, in handle_death_penalty
    raise self._exception('Task exceeded maximum timeout value ({0} seconds)'.format(self._timeout))
rq.timeouts.JobTimeoutException: Task exceeded maximum timeout value (300 seconds)

This happens because ScriptView passes job_timeout into ScriptJob,

but rescheduling mechanism does not pass this argument into enqueue method

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions