Skip to content

Unable to query racks after migration #4056

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

Closed
henyxia opened this issue Jan 30, 2020 · 2 comments
Closed

Unable to query racks after migration #4056

henyxia opened this issue Jan 30, 2020 · 2 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@henyxia
Copy link

henyxia commented Jan 30, 2020

Environment

  • Python version: 3.7.6
  • NetBox version: 2.7.3

Steps to Reproduce

  1. GET on /api/dcim/racks/8381/

What did you expect to happen?

Get the rack information

Observed Behavior

A 500 page with the error:

<class 'KeyError'>

'1000'

Additional information

After some digging, I think the issue comes from some racks where the outer_unit field was improperly migrated (going from 2.6.5 to 2.7.3).
In the database, I can see:

netbox=> select count(1), outer_unit from dcim_rack group by outer_unit;

 count | outer_unit
-------+------------
     9 | 1000
  4413 |
(2 rows)

Note

The issue might be related to #3967

@DanSheps DanSheps added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application and removed status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Jan 30, 2020
@DanSheps
Copy link
Member

I just checked, the migration is there so this will need a test migration from 2.6.x, I will check later this afternoon and let you know

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Jan 30, 2020
@jeremystretch jeremystretch self-assigned this Jan 30, 2020
@jeremystretch
Copy link
Member

jeremystretch commented Jan 30, 2020

Yep, I see the issue. There's a typo in rack_outer_unit_to_slug(), similar to #4027. Will be fixed in the next release. Yet another example of something that should have been caught during the v2.7 beta, unfortunately.

As an immediate workaround, you can do this:

$ ./manage.py nbshell
### NetBox interactive shell (jstretch-workstation)
### Python 3.6.9 | Django 2.2.9 | NetBox 2.7.4-dev
### lsmodels() will show available models. Use help(<model>) for more info.
>>> Rack.objects.filter(outer_unit='1000').update(outer_unit='mm')
0
>>> Rack.objects.filter(outer_unit='2000').update(outer_unit='in')
0

(The number returned by either command indicates the number of rows that were updated.)

@jeremystretch jeremystretch pinned this issue Jan 30, 2020
@jeremystretch jeremystretch unpinned this issue Feb 5, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
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

3 participants