Per Script Worker Queue Setting #9830

Open
opened 2025-12-29 21:23:20 +01:00 by adam · 7 comments
Owner

Originally created by @jchambers2012 on GitHub (Jun 11, 2024).

NetBox version

v3.7.8 and v4.0.5

Feature type

New functionality

Proposed functionality

Looking to enhance the script subsystem to add support to specify what worker queue each script should be run in. This will allow critical scripts to run before background or scheduled scripts. This feature would add a new field in the scripts’ Meta possibly called “rq_queue_name” that can bypass the logic in get_queue_for_model and just use the user defined queue. If “rq_queue_name” is not set then the current function can be called to determine what queue the script should be map too.

Use case

We have a few CI/DI pipeline that hit the API to generate control files in a centralized location versus the logic be distributed across different project code. This simplifies management of the project files but these critical scripts must wait in the queue with other background and user run scripts delaying the running of them.

Some of our non-critical script that update data can take 5 minutes to run and they are not time critical like the CI/DI pipeline.

Database changes

I don’t think any models will need to be updated to support this functionality.

External dependencies

n/a

Originally created by @jchambers2012 on GitHub (Jun 11, 2024). ### NetBox version v3.7.8 and v4.0.5 ### Feature type New functionality ### Proposed functionality Looking to enhance the script subsystem to add support to specify what worker queue each script should be run in. This will allow critical scripts to run before background or scheduled scripts. This feature would add a new field in the scripts’ Meta possibly called “rq_queue_name” that can bypass the logic in get_queue_for_model and just use the user defined queue. If “rq_queue_name” is not set then the current function can be called to determine what queue the script should be map too. ### Use case We have a few CI/DI pipeline that hit the API to generate control files in a centralized location versus the logic be distributed across different project code. This simplifies management of the project files but these critical scripts must wait in the queue with other background and user run scripts delaying the running of them. Some of our non-critical script that update data can take 5 minutes to run and they are not time critical like the CI/DI pipeline. ### Database changes I don’t think any models will need to be updated to support this functionality. ### External dependencies n/a
adam added the type: featurecomplexity: mediumnetboxstatus: backlog labels 2025-12-29 21:23:20 +01:00
Author
Owner

@jchambers2012 commented on GitHub (Jun 11, 2024):

I mocked up what i think needs to be changed but have not tested - let me know if you want me to work on the feature

https://github.com/netbox-community/netbox/compare/develop...jchambers2012:netbox:script_rq_queue_name?expand=1

@jchambers2012 commented on GitHub (Jun 11, 2024): I mocked up what i think needs to be changed but have not tested - let me know if you want me to work on the feature https://github.com/netbox-community/netbox/compare/develop...jchambers2012:netbox:script_rq_queue_name?expand=1
Author
Owner

@arthanson commented on GitHub (Jun 12, 2024):

@jchambers2012 I've assigned it to you as you said you have some code for it.

@arthanson commented on GitHub (Jun 12, 2024): @jchambers2012 I've assigned it to you as you said you have some code for it.
Author
Owner

@jchambers2012 commented on GitHub (Jun 13, 2024):

Stimulation are working will try and button up the PR this afternoon if not tomorrow
image

image

@jchambers2012 commented on GitHub (Jun 13, 2024): Stimulation are working will try and button up the PR this afternoon if not tomorrow ![image](https://github.com/netbox-community/netbox/assets/6090690/764e5610-6be4-4bf7-96b4-cf4d1e7b0bce) ![image](https://github.com/netbox-community/netbox/assets/6090690/09ee0c8a-2d6b-4b64-a594-c15b1214ccc4)
Author
Owner

@github-actions[bot] commented on GitHub (Sep 12, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Sep 12, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Sep 23, 2024):

While I agree that it would be valuable to enable mapping custom scripts to specific worker queues, we'll need to address a reasonably flexible mechanism for doing so. Statically mapping each script via an attribute (as in PR #16552) is not sufficiently scalable or easy to manage.

@jeremystretch commented on GitHub (Sep 23, 2024): While I agree that it would be valuable to enable mapping custom scripts to specific worker queues, we'll need to address a reasonably flexible mechanism for doing so. Statically mapping each script via an attribute (as in PR #16552) is not sufficiently scalable or easy to manage.
Author
Owner

@alehaa commented on GitHub (Oct 9, 2024):

I propose splitting this into two tasks, maybe solving the issue of scalability:

  1. Add a queue parameter to Job.enqueue() and the JobRunner framework so that background jobs (including scripts) can define a worker queue to use. This can be any string, usually one of high, default or low. Plugins can also use their own custom queues if needed.
  2. Move the queue definition to a ChoiceSet and make it available in the Scripts form. Users would then only be able to select queues defined by NetBox administrators, not those defined by plugins. This should be quite flexible and not overwhelming. If needed, future changes to NetBox could map these defined queue choices to whatever a new scheduler would need.
@alehaa commented on GitHub (Oct 9, 2024): I propose splitting this into two tasks, maybe solving the issue of scalability: 1. Add a `queue` parameter to `Job.enqueue()` and the `JobRunner` framework so that background jobs (including scripts) can define a worker queue to use. This can be any string, usually one of `high`, `default` or `low`. Plugins can also use their own custom queues if needed. 2. Move the queue definition to a `ChoiceSet` and make it available in the `Scripts` form. Users would then only be able to select queues defined by NetBox administrators, not those defined by plugins. This should be quite flexible and not overwhelming. If needed, future changes to NetBox could map these defined queue choices to whatever a new scheduler would need.
Author
Owner

@github-actions[bot] commented on GitHub (Apr 25, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Apr 25, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9830