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

Moving primary ip address for a device to a new device generates Integrity error #11934

Closed
drossy opened this issue Mar 8, 2023 · 5 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@drossy
Copy link

drossy commented Mar 8, 2023

NetBox version

v3.4.5

Python version

3.8

Steps to Reproduce

We encountered this on our local version (3.4.2) but were able to reproduce on the demo instance (3.4.5)

  1. Browse to the edit page for an ipv4 address marked as primary ip for a device
  2. Change the device and interface to another device and interface, leave the "Make this the primary IP for the device/VM" box ticked
  3. Press Save

Expected Behavior

IP address is updated to be set as primary ip for the new device, and assigned to the new interface, and is no longer primary ip address for the old device and is no longer assigned to the old interface.

Observed Behavior

The web server displays:

<class 'django.db.utils.IntegrityError'>

duplicate key value violates unique constraint "dcim_device_primary_ip4_id_key"
DETAIL: Key (primary_ip4_id)=(185) already exists.

@drossy drossy added the type: bug A confirmed report of unexpected behavior in the application label Mar 8, 2023
@kkthxbye-code kkthxbye-code added the status: accepted This issue has been accepted for implementation label Mar 10, 2023
@kkthxbye-code kkthxbye-code self-assigned this Mar 10, 2023
@jeremystretch
Copy link
Member

IP address is updated to be set as primary ip for the new device, and assigned to the new interface, and is no longer primary ip address for the old device and is no longer assigned to the old interface.

I'm not sure this should be the desired behavior. Primary IPs are explicitly designated, so automatically nullifying their assignments seems dangerous. Rather than handling this automatically, it would be safer to instead raise a validation failure, calling to the user's attention that the IP is assigned as primary for its current parent.

@jeremystretch
Copy link
Member

Per #11905, this also concerns primary IP assignment for virtual machines.

@drossy
Copy link
Author

drossy commented Mar 21, 2023

I'm not sure this should be the desired behavior. Primary IPs are explicitly designated, so automatically nullifying their assignments seems dangerous. Rather than handling this automatically, it would be safer to instead raise a validation failure, calling to the user's attention that the IP is assigned as primary for its current parent.

I wouldn't have a problem with that, we're currently working round this issue by undesignated the ip as primary and then moving the ip.

@salfers
Copy link

salfers commented Mar 24, 2023

Closely related (I think this is what the reporter in #11905 was trying to say):

  • Have a device or VM with 1.2.3.4 assigned to one of the interfaces, 1.2.3.4 is also set as primary IP for the device
  • Edit the IP 1.2.3.4 and remove the device + interface assignment
  • Open the device page and see that 1.2.3.4 is still shown as primary IP

If you click edit and re-save the device the primary IP will automatically disappear, so this state is not stable.

@bitcollector1
Copy link

somewhere along the line it was a (2) step process from GUI to remove a primary IP and I thought it was kind of annoying. After an upgrade (not sure which) this requirement was removed and I was happy until I started running into this Primary IP still assigned even though the IP was removed from the interface itself!

This has been causing quite a few headaches, hopefully it gets fixed before too much longer.

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

Successfully merging a pull request may close this issue.

5 participants