question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Device primary_ip not being removed when removing address from interface

See original GitHub issue

Environment

  • Python version: 3.5.3
  • NetBox version: 2.6.2

Steps to Reproduce

  1. Add an interface (let’s call it ‘I1’) to a device (‘D1’), and then add an IP address (‘A1’) to that interface ‘I1’
  2. Set the tuple (Interface-I1, IP-A1) as the primary_ip for the device ‘D1’
  3. Assign that IP address to a new interface (‘I2’) owned by a different device (‘D2’)
  4. Try to set that new tuple (Interface-I2, IP-A1) as the primary IP for the device ‘D2’

Expected Behavior

As far as I can reassign the IP address to a new interface (which is completely logical), I should be able to set it as primary_ip on the new device.

Observed Behavior

Response from the UI (device edit): Device with this Primary IPv4 already exists. Response from the API (PATCH /api/dcim/devices/<device-D2_id>/):

HTTP 500:

duplicate key value violates unique constraint &quot;dcim_device_primary_ip4_id_key&quot;
DETAIL:  Key (primary_ip4_id)=(<IP-A1_id>) already exists.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jeremystretchcommented, Oct 9, 2019

To be clear, it is intended behavior to not let an IP be moved from device A to device B while being assigned as the primary IP for device A. The parent device/VM needs to be modified to remove the assignment as primary IP before the IP can be reassigned. However, there is currently no validation in place to prevent this (via the API), so I’m calling it a bug.

1reaction
juan-vgcommented, Sep 2, 2019

Are you telling me that this behaviour only happens when using the API? Is the UI the one triggering the release? 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing a primary IP address from a network interface
Ensure that you remove all the manually configured alias addresses for the interface. Step. To remove a primary IP address, enter the following...
Read more >
REmoving Ip address from FE interface - Cisco Community
The right way to do is to remove the secondary u want to change, using no form of the command, with a secondary...
Read more >
Why does removing an unused IP address from an interface ...
This changes the behaviour such that when a primary IP is removed, it will not flush the remaining addresses and instead will promote...
Read more >
Cannot remove the IP address because it is the primary IP ...
Plesk IP address cannot be removed: Error: Cannot remove the IP address 203.0.113.2 because it is the primary IP address of a network...
Read more >
I want to change the primary IP on my nic but the console is ...
How can I swap primary for secondary nic on the interface? ... So deleting the only private IP address associated with your primary...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found