netbox-bgp
netbox-bgp copied to clipboard
Errors after upgrading to Netbox 3.3.4
NetBox version What version of NetBox are you currently running? 3.3.4 in Docker
Describe the bug A clear and concise description of what the bug is. NetBox will not load.
To Reproduce
Steps to reproduce the behavior:
Update the from field in my dockerfile to: FROM netboxcommunity/netbox:v3.3.4
run docker-compose build --no-cache (Check Portainer to see if new image has been created)
In Portainer, delete the running netbox containers
In Portainer, update my NetBox stack to redeploy new NetBox app containers.
Watch the logs on the NetBox container.
Container gets stuck on final error line (below).
Comment out netbox_bgp from plugins.py file
Container/NetBox loads just fine.
Readd netbox_bgp to plugins.py file
Issue returns (but without all the full migrations entries)
Readd comment to plugins.py to get NetBox working.
Expected behavior NetBox to load on current version with Plugins.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
I watched the logs go through and apply migrations.
Logs:
🧬 loaded config '/etc/netbox/config/plugins.py' Operations to perform: Apply all migrations: admin, auth, circuits, contenttypes, dcim, django_rq, extras, ipam, netbox_bgp, netbox_dns, netbox_documents, sessions, social_django, taggit, tenancy, users, virtualization, wireless Running migrations: Traceback (most recent call last): File "/opt/netbox/netbox/./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 98, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 290, in handle post_migrate_state = executor.migrate( File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 131, in migrate state = self._migrate_all_forwards( File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards state = self.apply_migration( File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 248, in apply_migration state = migration.apply(state, schema_editor) File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 131, in apply operation.database_forwards( File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards self.code(from_state.apps, schema_editor) File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_bgp/migrations/0026_netbox_bgp.py", line 20, in use_core_asn bgpsession.local_as = CoreASN.objects.get(asn=old_local_as).id File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 496, in get raise self.model.DoesNotExist( __fake__.ASN.DoesNotExist: ASN matching query does not exist.
I also have this issue after trying to upgrade to netbox 3.3.5. Any solution?
Edit: This bug seems to be present for me in all 3.3.x releases, back to 3.3.0. Using version 0.8.1 of the bgp-plugin
Applying database migrations (python3 netbox/manage.py migrate)...
Operations to perform:
Apply all migrations: admin, auth, circuits, contenttypes, dcim, django_rq, extras, ipam, netbox_bgp, sessions, social_django, taggit, tenancy, users, virtualization, wireless
Running migrations:
Applying netbox_bgp.0026_netbox_bgp...Traceback (most recent call last):
File "netbox/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 290, in handle
post_migrate_state = executor.migrate(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 131, in migrate
state = self._migrate_all_forwards(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards
state = self.apply_migration(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 248, in apply_migration
state = migration.apply(state, schema_editor)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 131, in apply
operation.database_forwards(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/netbox_bgp/migrations/0026_netbox_bgp.py", line 20, in use_core_asn
bgpsession.local_as = CoreASN.objects.get(asn=old_local_as).id
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/models/query.py", line 496, in get
raise self.model.DoesNotExist(
__fake__.DoesNotExist: ASN matching query does not exist.
Since 0.8.0 plugin ASN model was replaced to Core ASN model. Before upgrade to 0.8.1 you should create Core ASN's objects for all BGP Sessions.
Thanks for replying. So I should take all of the ASNs I have created under Plugins > BGP > AS Numbers and re-create them under IPAM > ASNs? Do I need to remove the old ASNs under the BGP plugin, or does the update take care of that?
I just went through the upgrade process again, after creating all the ASNs under IPAM > ASNs and receive the same error, is there something else I need to do here?
Applying netbox_bgp.0026_netbox_bgp...Traceback (most recent call last):
File "netbox/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/base.py", line 98, in wrapped
res = handle_func(*args, **kwargs)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 290, in handle
post_migrate_state = executor.migrate(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 131, in migrate
state = self._migrate_all_forwards(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards
state = self.apply_migration(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 248, in apply_migration
state = migration.apply(state, schema_editor)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 131, in apply
operation.database_forwards(
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/netbox_bgp/migrations/0026_netbox_bgp.py", line 20, in use_core_asn
bgpsession.local_as = CoreASN.objects.get(asn=old_local_as).id
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/netbox-3.3.0/venv/lib/python3.8/site-packages/django/db/models/query.py", line 496, in get
raise self.model.DoesNotExist(
__fake__.DoesNotExist: ASN matching query does not exist.
In case anyone stumbles on this later, this was caused by attempting to update directly from BGP Plugin 0.6.0 to 0.8.1. What I needed to do was.
- Update BGP Plugin to 0.7.0
- Migrate ASNs using the Migrate button in the GUI. Simply creating the ASNs did not work, I needed to explicitly push the Migrate button
- Update BGP Plugin to 0.8.0
- Update netbox to 3.3.0 and BGP plugin to 0.8.1
- Update Netbox to 3.3.10
I found that any other method failed (such as upgrading to 3.3.10 directly). Hopefully this helps someone else down the road.
That's not best solution for migration to Core ASN model which was made. I was expecting some side effects but due to time limit didn't more tests. Anyway thanks for reporting.
Howdy, I did end up getting it fixed on 3.3 by editing the database directly and deleting the reference ASNs. I forget exactly what table I edited.
I think that @chris-windscribe method would be the better method to fix it.