Data Sources remove sync interval #11840

Open
opened 2025-12-29 21:50:30 +01:00 by adam · 3 comments
Owner

Originally created by @kollross on GitHub (Nov 17, 2025).

Originally assigned to: @ifoughal on GitHub.

NetBox Edition

NetBox Community

NetBox Version

v4.4.6

Python Version

3.10

Steps to Reproduce

  1. Create new Data Source (git)
  2. Leave the Sync Interval blank
  3. After creation the "Sync" button is active and functional.
  4. Edit the sync internal and set it to anything.
  5. Save
  6. Sync button becomes inactive.
  7. Edit the sync internal and remove the existing sync interval
  8. Save
  9. Status still shows as "Queued" and sync button is still grayed out.
  10. The job was removed from the Jobs Queue.
  11. The data source never changes out of Queue state, nor does the Sync button ever become active.

Expected Behavior

Removing Sync Internal should re-enable the Sync button and change the status to Active.

Observed Behavior

Status still shows as Queued and Sync button is grayed out.

Originally created by @kollross on GitHub (Nov 17, 2025). Originally assigned to: @ifoughal on GitHub. ### NetBox Edition NetBox Community ### NetBox Version v4.4.6 ### Python Version 3.10 ### Steps to Reproduce 1. Create new Data Source (git) 2. Leave the Sync Interval blank 3. After creation the "Sync" button is active and functional. 4. Edit the sync internal and set it to anything. 5. Save 6. Sync button becomes inactive. 7. Edit the sync internal and remove the existing sync interval 8. Save 9. Status still shows as "Queued" and sync button is still grayed out. 10. The job was removed from the Jobs Queue. 11. The data source never changes out of Queue state, nor does the Sync button ever become active. ### Expected Behavior Removing Sync Internal should re-enable the Sync button and change the status to Active. ### Observed Behavior Status still shows as Queued and Sync button is grayed out.
adam added the type: bugstatus: acceptednetboxseverity: medium labels 2025-12-29 21:50:30 +01:00
Author
Owner

@ifoughal commented on GitHub (Nov 18, 2025):

as simple fix would be to include the NEW state to:

@property
   def ready_for_sync(self):
       return self.enabled and self.status not in (
           DataSourceStatusChoices.QUEUED,
           DataSourceStatusChoices.SYNCING
       )

changes to:

@property
   def ready_for_sync(self):
       return self.enabled and self.status in (
           DataSourceStatusChoices.SYNCING,
       )

This would allow users to sync their data-sources outside of the scheduled syncs by clicking manually.

As for the status of the data-source. It must be reset to .NEW by checking if the update payload has omited the schedule. This would take require more effort and testing.

I have attempted to fix this by changing the DataSourceForm by adding a clean override method:

def clean(self):
        super().clean()
        # check if self.sync_interval is null when enabled is True
        if not self.cleaned_data.get('sync_interval'):
            self.cleaned_data['status'] = DataSourceStatusChoices.NEW
        return self.cleaned_data

but the issue with this logic, is that we would have to render the status editable by the user, therefore could cause issues. I tried adding it to self.backend_fields:

self.backend_fields = ["status"]

This unfortunately also renders it as they both call the fieldset method, which currently has no option to hide the inputs.

@ifoughal commented on GitHub (Nov 18, 2025): as simple fix would be to include the NEW state to: ``` @property def ready_for_sync(self): return self.enabled and self.status not in ( DataSourceStatusChoices.QUEUED, DataSourceStatusChoices.SYNCING ) ``` changes to: ``` @property def ready_for_sync(self): return self.enabled and self.status in ( DataSourceStatusChoices.SYNCING, ) ``` This would allow users to sync their data-sources outside of the scheduled syncs by clicking manually. As for the status of the data-source. It must be reset to .NEW by checking if the update payload has omited the schedule. This would take require more effort and testing. I have attempted to fix this by changing the DataSourceForm by adding a clean override method: ``` def clean(self): super().clean() # check if self.sync_interval is null when enabled is True if not self.cleaned_data.get('sync_interval'): self.cleaned_data['status'] = DataSourceStatusChoices.NEW return self.cleaned_data ``` but the issue with this logic, is that we would have to render the status editable by the user, therefore could cause issues. I tried adding it to ```self.backend_fields```: ``` self.backend_fields = ["status"] ``` This unfortunately also renders it as they both call the fieldset method, which currently has no option to hide the inputs.
Author
Owner

@ifoughal commented on GitHub (Nov 19, 2025):

@jnovinger are you working on a fix for this one?

I have a fix ready, I have applied both logics described in my previous comment.

So my patch does the following:

  • Fixes the status update when the user sets a sync intervals.
  • Allows the user to sync manually even when a scheduled sync is applied.
@ifoughal commented on GitHub (Nov 19, 2025): @jnovinger are you working on a fix for this one? I have a fix ready, I have applied both logics described in my previous comment. So my patch does the following: - Fixes the status update when the user sets a sync intervals. - Allows the user to sync manually even when a scheduled sync is applied.
Author
Owner

@jnovinger commented on GitHub (Nov 19, 2025):

@ifoughal, apologies, I had meant to get to this yesterday but ran out of time. Happy to hand it over to you. Thanks!

@jnovinger commented on GitHub (Nov 19, 2025): @ifoughal, apologies, I had meant to get to this yesterday but ran out of time. Happy to hand it over to you. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11840