Skip to content

Commit

Permalink
Fixes: #17923, #17921 - Fix non-null constraint for script execution (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
alehaa authored Nov 21, 2024
1 parent 9ccbb08 commit 09a0e57
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions netbox/extras/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class ScriptJob(JobRunner):
"""

class Meta:
# An explicit job name is not set because it doesn't make sense in this context. Currently, there's no scenario
# where jobs other than this one are used. Therefore, it is hidden, resulting in a cleaner job table overview.
name = ''
name = 'Run Script'

def run_script(self, script, request, data, commit):
"""
Expand Down
1 change: 0 additions & 1 deletion netbox/extras/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,6 @@ def post(self, request, **kwargs):
request=copy_safe_request(request),
job_timeout=script.python_class.job_timeout,
commit=form.cleaned_data.pop('_commit'),
name=script.name
)

return redirect('extras:script_result', job_pk=job.pk)
Expand Down
1 change: 1 addition & 0 deletions netbox/netbox/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def handle(cls, job, *args, **kwargs):
kwargs["job_timeout"] = job.object.python_class.job_timeout
cls.enqueue(
instance=job.object,
name=job.name,
user=job.user,
schedule_at=new_scheduled_time,
interval=job.interval,
Expand Down

0 comments on commit 09a0e57

Please sign in to comment.