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 Script Scheduling Broken #17921

Closed
wz4 opened this issue Nov 2, 2024 · 3 comments · Fixed by #17932
Closed

Custom Script Scheduling Broken #17921

wz4 opened this issue Nov 2, 2024 · 3 comments · Fixed by #17932
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

@wz4
Copy link

wz4 commented Nov 2, 2024

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.6

Python Version

3.10

Steps to Reproduce

In Netbox v4.1.6 schedule a recurring custom script. The first job will get scheduled, but subsequent jobs are not.

Test Script

from extras.scripts import Script

class TestScript(Script):
    class Meta:
        name = "Test Script"
        description = "Hello"
        scheduling_enabled = True

    def run(self, data, commit):

        return "HELLO"

Expected Behavior

After a scheduled job completes, the next scheduled job should appear with a status of 'Scheduled'.

Observed Behavior

No observed error

@wz4 wz4 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 2, 2024
@arthanson arthanson added status: accepted This issue has been accepted for 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 Nov 4, 2024
@arthanson
Copy link
Collaborator

@alehaa can you comment on this and I can assign your.

@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed status: accepted This issue has been accepted for implementation labels Nov 4, 2024
@alehaa
Copy link
Contributor

alehaa commented Nov 4, 2024

I can take a look at it.

@alehaa
Copy link
Contributor

alehaa commented Nov 4, 2024

I believe this is related to #17923, as I get this error on the worker console:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.12/site-packages/rq/worker.py", line 1430, in perform_job
    rv = job.perform()
         ^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/rq/job.py", line 1280, in perform
    self._result = self._execute()
                   ^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/rq/job.py", line 1317, in _execute
    result = self.func(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/netbox/jobs.py", line 73, in handle
    cls.enqueue(
  File "/opt/netbox/netbox/netbox/jobs.py", line 106, in enqueue
    return Job.enqueue(cls.handle, name=name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/netbox/core/models/jobs.py", line 236, in enqueue
    job.full_clean()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1561, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']}

After applying the patch for #17923 jobs will be scheduled as expected again.

@arthanson arthanson 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 Nov 5, 2024
jeremystretch pushed a commit that referenced this issue Nov 21, 2024
…17932)

* Fix non-null constraint for script execution

With c34a0e2, validation of job object fields is enabled, so ScriptJob
must not set required fields to empty strings. This commit reverts
b18f193 and (hopefully) fixes this issue not only for UI views, but for
all interactions with scripts.

Fixes: #17923

* Fix name of recurring jobs

For recurring jobs, the name must be passed to the next job object when
the job is rescheduled.
This was referenced Nov 21, 2024
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.

4 participants