Просмотр исходного кода

Fixes #12105: Prevent data sources from becoming stuck in syncing status when an exception is raised

jeremystretch 2 лет назад
Родитель
Сommit
bd38b50e5e
2 измененных файлов с 7 добавлено и 3 удалено
  1. 2 1
      docs/release-notes/version-3.5.md
  2. 5 2
      netbox/core/jobs.py

+ 2 - 1
docs/release-notes/version-3.5.md

@@ -70,6 +70,7 @@ Two new webhook trigger events have been introduced: `job_start` and `job_end`.
 
 ### Bug Fixes (From Beta1)
 
+* [#12105](https://github.com/netbox-community/netbox/issues/12105) - Prevent data sources from becoming stuck in "syncing" status when an exception is raised
 * [#12106](https://github.com/netbox-community/netbox/issues/12106) - Fix exception when saving dashboard widget with minimum width/height
 * [#12108](https://github.com/netbox-community/netbox/issues/12108) - Limit the draggable area of widgets to their headers
 * [#12109](https://github.com/netbox-community/netbox/issues/12109) - Fix migration error when replicating more than 100 job results
@@ -79,7 +80,7 @@ Two new webhook trigger events have been introduced: `job_start` and `job_end`.
 
 * [#10604](https://github.com/netbox-community/netbox/issues/10604) - Remove unused `extra_tabs` block from `object.html` generic template
 * [#10923](https://github.com/netbox-community/netbox/issues/10923) - Remove unused `NetBoxModelCSVForm` class (replaced by `NetBoxModelImportForm`)
-* [#11489](https://github.com/netbox-community/netbox/issues/11489) - Consoldated several middleware classes
+* [#11489](https://github.com/netbox-community/netbox/issues/11489) - Consolidated several middleware classes
 * [#11611](https://github.com/netbox-community/netbox/issues/11611) - Refactor API viewset classes and introduce NetBoxReadOnlyModelViewSet
 * [#11694](https://github.com/netbox-community/netbox/issues/11694) - Remove obsolete `SmallTextarea` form widget
 * [#11737](https://github.com/netbox-community/netbox/issues/11737) - `ChangeLoggedModel` now inherits `WebhooksMixin`

+ 5 - 2
netbox/core/jobs.py

@@ -24,7 +24,10 @@ def sync_datasource(job, *args, **kwargs):
 
         job.terminate()
 
-    except (SyncError, JobTimeoutException) as e:
+    except Exception as e:
         job.terminate(status=JobStatusChoices.STATUS_ERRORED)
         DataSource.objects.filter(pk=datasource.pk).update(status=DataSourceStatusChoices.FAILED)
-        logging.error(e)
+        if type(e) in (SyncError, JobTimeoutException):
+            logging.error(e)
+        else:
+            raise e