Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
miaow2 opened this issue Oct 15, 2024 · 3 comments · Fixed by #17770
Closed

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

miaow2 opened this issue Oct 15, 2024 · 3 comments · Fixed by #17770
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@miaow2
Copy link
Contributor

miaow2 commented Oct 15, 2024

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

@miaow2 miaow2 added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Oct 15, 2024
@miaow2 miaow2 changed the title Custom scripts with job_timeout more then RQ_DEFAULT_TIMEOUT failed when rescheduled Custom scripts with job_timeout more than RQ_DEFAULT_TIMEOUT failed when rescheduled Oct 15, 2024
@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Oct 15, 2024
@arthanson
Copy link
Collaborator

@miaow2 it looks like you know where this is, do you want to work on a fix for it?

@miaow2
Copy link
Contributor Author

miaow2 commented Oct 15, 2024

@arthanson yeah, I want to work on this fix

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Oct 15, 2024
@jeremystretch
Copy link
Member

Thanks @miaow2, I've assigned this to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants