netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Data Sources remove sync interval

Open kollross opened this issue 1 month ago • 3 comments

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.

kollross avatar Nov 17 '25 15:11 kollross

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 avatar Nov 18 '25 14:11 ifoughal

@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 avatar Nov 19 '25 06:11 ifoughal

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

jnovinger avatar Nov 19 '25 14:11 jnovinger