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

15692: Introduce background jobs #16699

Closed

Conversation

alehaa
Copy link
Contributor

@alehaa alehaa commented Jun 24, 2024

Fixes: #15692

This PR includes three new background job class to be used in NetBox and by NetBox plugins. They handle the necessary logic for starting and stopping jobs, including exception handling and rescheduling of recurring jobs.

This PR also implements the use of this framework for existing data source and script jobs, eliminating duplicate code and ensuring consistency.

A new abstract class can be used to implement job function classes. It
handles the necessary logic for starting and stopping jobs, including
exception handling and rescheduling of recurring jobs.

This commit also includes the migration of data source jobs to the new
framework.
Using the 'import_string()' utility from Django allows the job script
class to be simplified, as module imports no longer need to avoid loops.
This should make it easier to queue and maintain jobs.
Instead of maintaining two separate job execution logics, the same job
is now used for both background and interactive execution.
The independent implementations of interactive and background script
execution have been merged into a single BackgroundJob implementation.
@jeremystretch jeremystretch added this to the v4.1 milestone Jun 25, 2024
A new abstract class can be used to implement job function classes that
specialize in scheduling. These use the same logic as regular
BackgroundJobs, but ensure that they are only scheduled once at any given
time.
A new abstract class can be used to implement job function classes that
specialize in system background tasks (e.g. synchronization or
housekeeping). In addition to the features of the BackgroundJob and
ScheduledJob classes, these implement additional logic to not need to be
bound to an existing NetBox object and to setup job schedules on plugin
load instead of an interactive request.
@alehaa alehaa marked this pull request as ready for review July 1, 2024 23:17
@jeremystretch
Copy link
Member

@alehaa sorry, we haven't forgotten about this, just backlogged on the v4.1 work currently. Hoping to review this this week.

@jeremystretch
Copy link
Member

@alehaa actually would it be possible for you to rename your branch? It conflicts with our feature branch when trying to check it out. Just 15692-background-jobs would be ideal.

@alehaa alehaa closed this Jul 16, 2024
@alehaa alehaa deleted the feature/15692-background-jobs branch July 16, 2024 21:08
@alehaa
Copy link
Contributor Author

alehaa commented Jul 16, 2024

@jeremystretch unfortunately GitHub did close this PR because of renaming the branch. I've filed #16927 instead and also removed some merge conflicts to the feature branch in my latest commit.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants