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

Job scheduling is not working #18004

Open
miaow2 opened this issue Nov 13, 2024 · 1 comment
Open

Job scheduling is not working #18004

miaow2 opened this issue Nov 13, 2024 · 1 comment
Labels
status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application

Comments

@miaow2
Copy link
Contributor

miaow2 commented Nov 13, 2024

Deployment Type

Self-hosted

Triage priority

I volunteer to perform this work (if approved)

NetBox Version

v4.1.6

Python Version

3.11

Steps to Reproduce

  1. Create any script
from extras.scripts import Script


class TestScript(Script):

    def run(self, data, commit):
        self.log_info("This is test script")
  1. Run the script with any interval set
    image

Expected Behavior

The script successfully runs and creates a new scheduled job

Observed Behavior

A new job is not scheduled, traceback from worker

13:48:59 default: handle(commit=True, data={}, job=<Job: 086a5aae-5c60-4746-bde4-f77800c795ea>, request=<utilities.request.NetBoxFakeRequest object at 0x7fba0c3b7ef0>) (086a5aae-5c60-4746-bde4-f77800c795ea)
13:48:59 [Job 086a5aae-5c60-4746-bde4-f77800c795ea]: exception raised while executing (handle)
Traceback (most recent call last):
  File "/home/miaow/work/netbox/venv/lib/python3.12/site-packages/rq/worker.py", line 1430, in perform_job
    rv = job.perform()
         ^^^^^^^^^^^^^
  File "/home/miaow/work/netbox/venv/lib/python3.12/site-packages/rq/job.py", line 1280, in perform
    self._result = self._execute()
                   ^^^^^^^^^^^^^^^
  File "/home/miaow/work/netbox/venv/lib/python3.12/site-packages/rq/job.py", line 1317, in _execute
    result = self.func(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miaow/work/netbox/netbox/netbox/jobs.py", line 74, in handle
    cls.enqueue(
  File "/home/miaow/work/netbox/netbox/netbox/jobs.py", line 107, in enqueue
    return Job.enqueue(cls.handle, name=name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miaow/work/netbox/netbox/core/models/jobs.py", line 237, in enqueue
    job.full_clean()
  File "/home/miaow/work/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1502, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']}

This happens because the rescheduling mechanism does not pass name to the Job enqueue and name field is obligatory in Job model.

This can be fixed by passing job.name to cls.enqueue here.

Feel free to assign this issue to me, I will create PR to fix this issue.A new

@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 Nov 13, 2024
@alehaa
Copy link
Contributor

alehaa commented Nov 13, 2024

This issue is a duplicate of #17923, #17921. A PR is already provided and ready to merge. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants