netboxlabs / netbox-branching

Official NetBox Labs plugin that implements git-like branching functionality for NetBox
http://netboxlabs.com
Other
63 stars 1 forks source link

Branching support not enabled for plugins listed after `netbox_branching` in `PLUGINS` config parameter #114

Open jeremystretch opened 1 month ago

jeremystretch commented 1 month ago

Plugin Version

v0.4.0

NetBox Version

v4.1.0

Python Version

3.10

Steps to Reproduce

  1. Install netbox_dns (or a similar functional plugin)
  2. Configure PLUGINS as:
PLUGINS = [
    'netbox_branching',
    'netbox_dns',
]
  1. Enter the Python shell (manage.py nbshell) and inspect model registration for branching support. Note that netbox_dns is absent from the list of recognized apps.
>>> from netbox.registry import registry
>>> registry['model_features']['branching'].keys()
dict_keys(['core', 'circuits', 'dcim', 'ipam', 'extras', 'tenancy', 'virtualization', 'vpn', 'wireless'])
  1. Exit the shell and redefine PLUGINS as:
PLUGINS = [
    'netbox_dns',
    'netbox_branching',
]
  1. Enter the Python shell and again inspect the registered models. netbox_dns is now included in the list of apps.
>>> from netbox.registry import registry
>>> registry['model_features']['branching'].keys()
dict_keys(['core', 'circuits', 'dcim', 'ipam', 'extras', 'tenancy', 'virtualization', 'vpn', 'wireless', 'netbox_dns'])

Expected Behavior

Branching support for all plugins should be registered regardless of the order in which plugins are loaded.

Observed Behavior

Branching support is registered only for plugins which are listed before netbox_branching in the PLUGINS list.

jeremystretch commented 1 month ago

Dug into this a bit. It can be addressed by iterating through apps.get_models() under the plugin's ready() method, however we still have an issue determining change logging support for models because registration of that feature is affected by the same race condition.

jeremystretch commented 1 month ago

We've worked around this temporarily by documenting the need to list netbox_branching at the end of the PLUGINS list (see #115).