[PR #20837] Closes 20817 fix datasource sync broken when cron is set #16062

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20837
Author: @ifoughal
Created: 11/19/2025
Status: 🔄 Open

Base: mainHead: closes-20817-Fix-datasource-sync-broken-when-cron-is-set


📝 Commits (10+)

  • b4160ad Feat: set status as editable field
  • 111aca1 Feat: added clean method to set data-source state to Ready or scheduled
  • bfeba36 Feat: added status update during save method of DataSourceForm
  • 2e0ff04 Feat: added 2 states for DataSourceStatusChoices
  • a49869a Feat: removed QUEUED from ready for sync condition
  • 5b5b5c8 Revert "Feat: set status as editable field"
  • e11508d Fix: removed status update from the enqueue method
  • 71f707b Feat: removed SCHEDULED choice due to redundency with sync interval
  • da4c669 Feat: reworked status update logic
  • 57b47dc style: use != instead of not in for single SYNCING check

📊 Changes

3 files changed (+19 additions, -5 deletions)

View changed files

📝 netbox/core/choices.py (+2 -0)
📝 netbox/core/forms/model_forms.py (+16 -1)
📝 netbox/core/models/data.py (+1 -4)

📄 Description

Fixes: #20817

Datasources sync was broken when the user sets a sync interval.

The fix introduces 2 new states:

  • Ready
  • Scheduled

Ready state is set when the data-source object is not new. ie: either updated or changed state recently.
Scheduled is set when the user sets a sync interval.

This PR includes the following logic enhancements:

  • by removing DataSourceStatusChoices.QUEUED from the ready_for_sync method, we let the user sync the data-source anytime even when a daily interval is set, as long as the data-source is enabled.

  • Include the 2 new states (Scheduled, Ready) in the clean & save properties of data-source form model, to set the status correctly depending on the user inputs/

    • If the user creates a new data-source object, then the state is new.
    • if the user update the object with a defined interval, then the states changes to scheduled
    • if the user removed the sync interval, then the state changes to Ready.
    • if a sync is completed either successfully or with a failure, then the status will get update with the job's status as before without impact.

🔄 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/20837 **Author:** [@ifoughal](https://github.com/ifoughal) **Created:** 11/19/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `closes-20817-Fix-datasource-sync-broken-when-cron-is-set` --- ### 📝 Commits (10+) - [`b4160ad`](https://github.com/netbox-community/netbox/commit/b4160ad59bdc1057b9761b7c5457afd9bcd754c3) Feat: set status as editable field - [`111aca1`](https://github.com/netbox-community/netbox/commit/111aca115b87c63d9cd02c84c120b3f796543294) Feat: added clean method to set data-source state to Ready or scheduled - [`bfeba36`](https://github.com/netbox-community/netbox/commit/bfeba365142c749fb6916482318cf4f7181998e3) Feat: added status update during save method of DataSourceForm - [`2e0ff04`](https://github.com/netbox-community/netbox/commit/2e0ff04f847374208e81995720410e8df43105ed) Feat: added 2 states for DataSourceStatusChoices - [`a49869a`](https://github.com/netbox-community/netbox/commit/a49869af420f35c08bed30e6e59492fe4d5d230f) Feat: removed QUEUED from ready for sync condition - [`5b5b5c8`](https://github.com/netbox-community/netbox/commit/5b5b5c8909a724a2ce20e42a8f21a91051c78f4d) Revert "Feat: set status as editable field" - [`e11508d`](https://github.com/netbox-community/netbox/commit/e11508dd6c31e357ce69f73ed8f8c8582599f695) Fix: removed status update from the enqueue method - [`71f707b`](https://github.com/netbox-community/netbox/commit/71f707b7ac649c9157f57b5eeb75e5f44dd95e66) Feat: removed SCHEDULED choice due to redundency with sync interval - [`da4c669`](https://github.com/netbox-community/netbox/commit/da4c6693122f627a5c0121650c3af7b7db877d8c) Feat: reworked status update logic - [`57b47dc`](https://github.com/netbox-community/netbox/commit/57b47dc1ea12db7e3524f8028e48840f1aaf74d3) style: use != instead of not in for single SYNCING check ### 📊 Changes **3 files changed** (+19 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `netbox/core/choices.py` (+2 -0) 📝 `netbox/core/forms/model_forms.py` (+16 -1) 📝 `netbox/core/models/data.py` (+1 -4) </details> ### 📄 Description ### Fixes: #20817 Datasources sync was broken when the user sets a sync interval. The fix introduces 2 new states: - Ready - Scheduled Ready state is set when the data-source object is not new. ie: either updated or changed state recently. Scheduled is set when the user sets a sync interval. This PR includes the following logic enhancements: - by removing ```DataSourceStatusChoices.QUEUED``` from the ```ready_for_sync``` method, we let the user sync the data-source anytime even when a daily interval is set, as long as the data-source is enabled. - Include the 2 new states (Scheduled, Ready) in the clean & save properties of data-source form model, to set the status correctly depending on the user inputs/ - If the user creates a new data-source object, then the state is new. - if the user update the object with a defined interval, then the states changes to scheduled - if the user removed the sync interval, then the state changes to Ready. - if a sync is completed either successfully or with a failure, then the status will get update with the job's status as before without impact. --- <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:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#16062