Skip to content
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

ValueError exception when migrating to v2.11.5 with one or more VRFs defined #6544

Closed
jeremystretch opened this issue Jun 4, 2021 · 1 comment
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jeremystretch
Copy link
Member

NetBox version

v2.11.5

Python version

3.7

Steps to Reproduce

  1. Start with NetBox v2.11.4 or earlier
  2. Create a VRF
  3. Create one or more prefixes within that VRF
  4. Upgrade to NetBox v2.11.5

Expected Behavior

The upgrade should complete successfully.

Observed Behavior

A ValueError exception is raised due to a bug in the way VRFs are retrieved in the migration:

ValueError: Cannot query "VRF object (1)": Must be "VRF" instance.

It seems that Django does not like using the "faked" VRF instance returned by apps.get_model() for filtering. It's being cast as a string by filter() rather than its numeric ID beign evaluated.

VRF = apps.get_model('ipam', 'VRF')
...
    # Iterate through all VRFs, rebuilding each
    for vrf in VRF.objects.all():
        rebuild_prefixes(vrf)

Altering the migration to reference the ID directly resolves the issue:

        rebuild_prefixes(vrf.pk)
$ ./manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization
Running migrations:
  Applying ipam.0048_prefix_populate_depth_children...
Updating 3157 prefixes...
 OK
@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Jun 4, 2021
@jeremystretch jeremystretch self-assigned this Jun 4, 2021
@jeremystretch jeremystretch pinned this issue Jun 4, 2021
@jeremystretch jeremystretch unpinned this issue Jun 4, 2021
@maznu
Copy link

maznu commented Jun 5, 2021

Thanks for fixing this one so quickly, @jeremystretch!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants