primary IP is set even when IP doesn't belong to the VM #8313

Closed
opened 2025-12-29 20:35:13 +01:00 by adam · 1 comment
Owner

Originally created by @lethargosapatheia on GitHub (Jul 10, 2023).

Originally assigned to: @arthanson on GitHub.

NetBox version

v3.5.5

Python version

3.8

Steps to Reproduce

When I am reassigning an IP to another virtual machine, the IP is still set as a primary IP for the initial virtual virtual machine.
I have two virtual machines, ceph-mon-001(network interface id: 40) and ceph-mon-002 (network interface id: 92)

curl -H "Authorization: Token <TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" -X PATCH -d '{"assigned_object_id": 40}' https://netbox-company.com/api/ipam/ip-addresses/735/

So in this case I'm reassigning IP id 735 (10.88.88.176/24) from the network id of ceph-mon-002 (92) to the network id of ceph-mon-001 (40).

At this point ceph-mon-002's only network interface has no ip at all. Nonetheless I'm still seeing the ip 10.88.88.176 as primary IP:
ceph-mon-002

Tested with the API:

curl -H "Authorization: Token <TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" -X GET https://netbox-company.com/api/virtualization/virtual-machines/72/
{
  "id": 735,
  "url": "https://netbox-company.com/api/ipam/ip-addresses/735/",
  "display": "10.88.88.176/24",
  "family": 4,
  "address": "10.88.88.176/24"
}
{
  "id": 735,
  "url": "https://netbox-company.com/api/ipam/ip-addresses/735/",
  "display": "10.88.88.176/24",
  "family": 4,
  "address": "10.88.88.176/24"
}

Expected Behavior

I expect that the primary VM disappears from the initial virtual machine.

Observed Behavior

It's still there :)

This is seems to be the same issue reported here https://github.com/netbox-community/netbox/issues/12953

Something really similar was reported in 2018 https://github.com/netbox-community/netbox/issues/2342
(related specifically to this: https://github.com/netbox-community/netbox/issues/2399)

So this keeps coming backup.

I'm using this in Ubuntu 22.04.2. Netbox is directly installed on the host. Postgresql 13.10 is installed.

Originally created by @lethargosapatheia on GitHub (Jul 10, 2023). Originally assigned to: @arthanson on GitHub. ### NetBox version v3.5.5 ### Python version 3.8 ### Steps to Reproduce When I am reassigning an IP to another virtual machine, the IP is still set as a primary IP for the initial virtual virtual machine. I have two virtual machines, `ceph-mon-001`(network interface id: 40) and `ceph-mon-002` (network interface id: 92) ``` curl -H "Authorization: Token <TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" -X PATCH -d '{"assigned_object_id": 40}' https://netbox-company.com/api/ipam/ip-addresses/735/ ``` So in this case I'm reassigning IP id `735` (`10.88.88.176/24`) from the network id of ceph-mon-002 (`92`) to the network id of ceph-mon-001 (`40`). At this point ceph-mon-002's only network interface has no ip at all. Nonetheless I'm still seeing the ip `10.88.88.176` as primary IP: <img width="711" alt="ceph-mon-002" src="https://github.com/netbox-community/netbox/assets/22618815/c6bfe53c-bf46-4410-8cb8-535343fff9e2"> Tested with the API: ``` curl -H "Authorization: Token <TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" -X GET https://netbox-company.com/api/virtualization/virtual-machines/72/ ``` ```json { "id": 735, "url": "https://netbox-company.com/api/ipam/ip-addresses/735/", "display": "10.88.88.176/24", "family": 4, "address": "10.88.88.176/24" } { "id": 735, "url": "https://netbox-company.com/api/ipam/ip-addresses/735/", "display": "10.88.88.176/24", "family": 4, "address": "10.88.88.176/24" } ``` ### Expected Behavior I expect that the primary VM disappears from the initial virtual machine. ### Observed Behavior It's still there :) This is seems to be the same issue reported here https://github.com/netbox-community/netbox/issues/12953 Something really similar was reported in 2018 https://github.com/netbox-community/netbox/issues/2342 (related specifically to this: https://github.com/netbox-community/netbox/issues/2399) So this keeps coming backup. I'm using this in Ubuntu 22.04.2. Netbox is directly installed on the host. Postgresql 13.10 is installed.
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 20:35:13 +01:00
adam closed this issue 2025-12-29 20:35:14 +01:00
Author
Owner

@jsenecal commented on GitHub (Jul 10, 2023):

This is probably caused by the fact that the Signal to clear the primary IP is only occurring upon deletion of the IPAddress (The relationship with the related object is not automatic). See: ipam/signals.py#L52C1-L64C30
This can probably be fixed by another signal but I need to try and replicate this first.

@jsenecal commented on GitHub (Jul 10, 2023): This is probably caused by the fact that the `Signal` to clear the primary IP is only occurring upon deletion of the `IPAddress` (The relationship with the related object is not automatic). See: [ipam/signals.py#L52C1-L64C30](https://github.com/netbox-community/netbox/blob/develop/netbox/ipam/signals.py#L52C1-L64C30) This can probably be fixed by another signal but I need to try and replicate this first.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8313