netbox
netbox copied to clipboard
Fixes #8366 - Add job scheduling
Fixes: #8366
This is a draft PR for adding job scheduling. Feel free to provide input.
Changes:
- Add a "Schedule at" form field to both the report and script form
- Add JobResult list view
- Add the
form-object-editclass to both forms to match the width of forms in the rest of netbox (previously they were full width). - Update the js
flatpickrdependency to fix issue with the DateTimeField automatically populating when losing focus. - Modify JobResult to delete RQ tasks to avoid running scheduled tasks with no JobResult associated
- Added new JobResultStatusChoice
Scheduled
To do:
- Adjust script/report result view to better convey that a task is scheduled.
- Add documentation for job scheduling
rqworkerneeds to be started with--with-scheduler- Create issue with netbox-docker before merge to make sure
--with-scheduleris added to the worker container launch cmd - Add general usage documentation
- Add job scheduling support to the API as well?
limit_choices_to=FeatureQuery('job_results'),doesn't work at all in filter forms and it doesn't seem to work in other filterforms either.
@kkthxbye-code thanks for taking this on. I wanted to note that since this has been tagged for v3.4, the PR should be based on the feature branch.
@jeremystretch - Thanks, didn't notice when I opened the PR that it was the wrong target branch, the actual branch was made off of feature though, so it shouldn't be an issue. I changed the target now :)
I think this is ready for initial review now @jeremystretch
There's some stuff I'm unsure about:
- I moved job results out of the admin panel. Do we want another list view called scheduled jobs? It would be the same exact table as the job results table, just filtered to only contain job results with the scheduled status.
- ~~Should I add support for scheduling jobs to the API as well?~~ Fixed
- Currently the way to cancel a job is to delete the associated job result. Do we want to add another method that just cancels the schedule but lets the job result instance be?
I probably forgot some stuff, but let me know if something is not clear when testing.
Do we want another list view called scheduled jobs?
Can we just add a filter for the primary list?
Currently the way to cancel a job is to delete the associated job result. Do we want to add another method that just cancels the schedule but lets the job result instance be?
Possibly; I'm happy to defer to feedback we receive during the beta cycle.
Can we just add a filter for the primary list?
It is already possible to filter by status in the JobResult view. We could add a menu item that links to the JobResult list with the status pre-filtered to Schedules but not sure if it is necessary.
Thank you for the review, I adressed what I could. Regarding the filtersets I'm gonna need some guidance.
Awesome work @kkthxbye-code! :raised_hands: