-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closes 20817 fix datasource sync broken when cron is set #20837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b4160ad
111aca1
bfeba36
2e0ff04
a49869a
5b5b5c8
e11508d
71f707b
da4c669
57b47dc
3016b1d
e4b6140
929d024
93e5f91
09d1049
77ee6ba
544c97d
cf16a29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,13 +13,15 @@ class DataSourceStatusChoices(ChoiceSet): | |||||
| SYNCING = 'syncing' | ||||||
| COMPLETED = 'completed' | ||||||
| FAILED = 'failed' | ||||||
| READY = 'ready' | ||||||
|
|
||||||
| CHOICES = ( | ||||||
| (NEW, _('New'), 'blue'), | ||||||
| (QUEUED, _('Queued'), 'orange'), | ||||||
| (SYNCING, _('Syncing'), 'cyan'), | ||||||
| (COMPLETED, _('Completed'), 'green'), | ||||||
| (FAILED, _('Failed'), 'red'), | ||||||
| (READY, _('Ready'), 'green'), | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You say SCHEDULED status is added but there is no scheduled in the status or code anywhere? Still confused as you state "The two new states are READY & SCHEDULED."
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up removing it, so there is only one state that has been added in the end, which is the The reasoning behind was that
|
||||||
| (READY, _('Ready'), 'green'), | |
| (READY, _('Ready'), 'gray'), |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||||
| from utilities.forms.fields import CommentField, JSONField | ||||||||
| from utilities.forms.rendering import FieldSet | ||||||||
| from utilities.forms.widgets import HTMXSelect | ||||||||
| from core.choices import DataSourceStatusChoices | ||||||||
|
|
||||||||
| __all__ = ( | ||||||||
| 'ConfigRevisionForm', | ||||||||
|
|
@@ -79,14 +80,28 @@ def __init__(self, *args, **kwargs): | |||||||
| if self.instance and self.instance.parameters: | ||||||||
| self.fields[field_name].initial = self.instance.parameters.get(name) | ||||||||
|
|
||||||||
| def save(self, *args, **kwargs): | ||||||||
|
|
||||||||
|
||||||||
| else: | |
| self.cleaned_data['status'] = DataSourceStatusChoices.QUEUED |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -111,10 +111,7 @@ def backend_class(self): | |||||||||||
|
|
||||||||||||
| @property | ||||||||||||
| def ready_for_sync(self): | ||||||||||||
| return self.enabled and self.status not in ( | ||||||||||||
| DataSourceStatusChoices.QUEUED, | ||||||||||||
| DataSourceStatusChoices.SYNCING | ||||||||||||
| ) | ||||||||||||
| return self.enabled and self.status != DataSourceStatusChoices.SYNCING | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: If we are adding the READY state and other changes here do we still need to skip QUEUED check here? Just wondering if your other changes will allow it to be kept as I think if it is actually queued and hasn't finished we probably don't want to allow sync again?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's why I had initially added the
what do you think?
|
||||||||||||
| return self.enabled and self.status != DataSourceStatusChoices.SYNCING | |
| return self.enabled and self.status not in ( | |
| DataSourceStatusChoices.SYNCING, | |
| DataSourceStatusChoices.QUEUED, | |
| ) |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modified ready_for_sync logic lacks test coverage. Given that this property is critical for determining when a DataSource can be synced and is a key part of the bug fix, tests should be added to verify the behavior with different status values (NEW, QUEUED, READY, COMPLETED, FAILED) and the enabled flag. Consider adding tests to netbox/core/tests/test_models.py to cover this property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description mentions introducing two new states: "Ready" and "Scheduled". However, only the READY state is added here. The SCHEDULED state is missing from the DataSourceStatusChoices. This means the logic described in the PR description for setting status to "Scheduled" when a user sets a sync interval cannot be implemented.