netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Fixes #8366 - Add job scheduling

Open kkthxbye-code opened this issue 3 years ago • 2 comments

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-edit class to both forms to match the width of forms in the rest of netbox (previously they were full width).
  • Update the js flatpickr dependency 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
    • rqworker needs to be started with --with-scheduler
    • Create issue with netbox-docker before merge to make sure --with-scheduler is 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 avatar Sep 20 '22 10:09 kkthxbye-code

@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 avatar Sep 26 '22 14:09 jeremystretch

@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 :)

kkthxbye-code avatar Sep 26 '22 14:09 kkthxbye-code

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.

kkthxbye-code avatar Oct 16 '22 16:10 kkthxbye-code

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.

jeremystretch avatar Oct 21 '22 01:10 jeremystretch

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.

kkthxbye-code avatar Oct 21 '22 08:10 kkthxbye-code

Awesome work @kkthxbye-code! :raised_hands:

jeremystretch avatar Oct 21 '22 15:10 jeremystretch