[PR #20879] [MERGED] 20878 use database routing when running script #16077

Closed
opened 2025-12-30 00:25:40 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20879
Author: @arthanson
Created: 11/25/2025
Status: Merged
Merged: 12/4/2025
Merged by: @jnovinger

Base: mainHead: 20878-script-run


📝 Commits (5)

  • 701561d 20878 use database routing when running script
  • 6094aa8 update comments
  • 5208e54 remove event_tracking processing if not commit
  • aec8e29 atomic lock on both default and potentially branch database
  • c4e28eb review changes

📊 Changes

1 file changed (+25 additions, -11 deletions)

View changed files

📝 netbox/extras/jobs.py (+25 -11)

📄 Description

Fixes: #20878

Two main changes were needed:

  • The atomic transaction wrapping the script needs to be done on default database and also the branch database as the script could potentially modify data in either. Device was picked as a branch aware model to get the correct db_for_write.
  • The request processor code needs to be run even if not committing in order to pick up the branch processor that actually switches to the branch. However the event_tracking request_processor needs to be skipped so it doesn't process events (like a web hook setup on data being modified).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20879 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 11/25/2025 **Status:** ✅ Merged **Merged:** 12/4/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `main` ← **Head:** `20878-script-run` --- ### 📝 Commits (5) - [`701561d`](https://github.com/netbox-community/netbox/commit/701561daa85882deba25ba5fbd4953744f6a2739) 20878 use database routing when running script - [`6094aa8`](https://github.com/netbox-community/netbox/commit/6094aa868208edf5b7a6c6c53040fd34063ad84b) update comments - [`5208e54`](https://github.com/netbox-community/netbox/commit/5208e544ce005b74fea91828b151e74b53a9f5f5) remove event_tracking processing if not commit - [`aec8e29`](https://github.com/netbox-community/netbox/commit/aec8e293bffc27ee58226b6441dc093c84755fa7) atomic lock on both default and potentially branch database - [`c4e28eb`](https://github.com/netbox-community/netbox/commit/c4e28ebf297f4bde59d771e3081c54cf0edb9883) review changes ### 📊 Changes **1 file changed** (+25 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/jobs.py` (+25 -11) </details> ### 📄 Description ### Fixes: #20878 Two main changes were needed: * The atomic transaction wrapping the script needs to be done on default database and also the branch database as the script could potentially modify data in either. Device was picked as a branch aware model to get the correct db_for_write. * The request processor code needs to be run even if not committing in order to pick up the branch processor that actually switches to the branch. However the event_tracking request_processor needs to be skipped so it doesn't process events (like a web hook setup on data being modified). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:25:40 +01:00
adam closed this issue 2025-12-30 00:25:40 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#16077