netbox-sync
netbox-sync copied to clipboard
IP address marked as orphaned when vNIC changes portgroup
Hi,
When switching the portgroup of 2 existing interfaces, that had IP addresses assigned to them, the IP's are marked as orphaned. They are also deleted according to the prune settings, and only during the sync that occurs after the delete action, they're added back to the changed interface.
More detail:
IP address 5.x.4.21/23 created by vcenter-sync
vrf: null
role: ""
tags: []
status: "active"
tenant: null
address: "5.x.4.21/23"
created: "2021-06-29"
dns_name: ""
nat_inside: null
description: ""
last_updated: "2021-06-29T06:04:44.508Z"
custom_fields: {}
assigned_object_id: 9378
assigned_object_type: 81
During same sync, the object is updated with the sync tags: IP address 5.x.4.21/23 updated by vcenter-sync
tags: [
"NetBox-synced",
"Source: com-vcenter008"
]
Weeks later, the VM gets a dist-upgrade and this causes Debian to mix up the interfaces after a reboot, and someone fixes this by changing the VM interfaces to the corresponding portgroups.
Situation before: vNIC1 -> HCL PUB 2489 vNIC2 -> portgroup abc vNIC3 -> portgroup def vNIC4 -> Netapp102 ClientMounts 3102
Situation after: vNIC1 -> Netapp102 ClientMounts 3102 vNIC2 -> portgroup abc vNIC3 -> portgroup def vNIC4 -> HCL PUB 2489
After this action, the sync log states:
WARNING: Current interface 'vNIC 1 (Netapp102 ClientMounts 3102) (com-vm022a.srv.masked-ops.net)' for IP '5.x.4.21/23' and this one 'vNIC 4 (HCL PUB 2489) (com-vm022a.srv.masked-ops.net)' are both enabled. IP assignment skipped because it is unclear which one is the correct one!
And the sync tags all the IP addresses of vNIC4 (previously vNIC1) as orphaned.
After the prune_delay_in_days
is over, the IP address is deleted.
Only on the first sync after the sync deleted the IP's, the IP addresses are added back, and assigned to the correct vNIC.
Is it possible to detect this and link the IP addresses to the correct vNIC, instead of having the current flow where there's a gap and it seems the IP address does not exist between the sync where the prune action happens & the first sync after that?
Hi,
You are correct, this is happening.
This would need a validation run to see if an IP address in NetBox is still assigned to the same interface.
I have to think about, how to solve this in the process logic.
Hey @gstorme,
I could actually easily add this. If the scope is the same device/VM then it is pretty straight forward.
in the long run you should think about switching to a different Linux distribution if this keeps happening. The network device order should not change on any system update.
Hey @gstorme,
I just pushed a change to "development" which should fix this issue. Can you please try it out if this resolves your issue?
Looks good, thanks!
Great, thank you for the feedback