Nova sends a request for port unbind with binding host "" and this can sometimes lead to a problem when nova's cache is different than Neutron's view of instance-port mappings.
Steps
1. Create a neutron port
2. Create a VM and launch instance with this port
3. Shutdown nova compute and neutron agents on compute node where this VM was spawned
4. Unbind port from VM and delete the VM(Notice offline delete is a DB operation as request cant be completed on compute node as it is down)
5. Now create a new VM with same port on a different compute node
6. Bring up nova compute on the first node
After 30 minutes the running deleted instance reap runs and detects a VM in libvirt which is not present in nova database. It cleans up the VM but in the process it unbinds the pre-existing port which is now attached to a completely different VM on a different compute node
Root cause: nova unbind request does not check if port is bound to current instance from Neutron standpoint
Tried following fix seemed to work network/ neutronv2/ api.py b/nova/ network/ neutronv2/ api.py network/ neutronv2/ api.py network/ neutronv2/ api.py api.NetworkAPI) :
diff --git a/nova/
index 7192031..c526393 100644
--- a/nova/
+++ b/nova/
@@ -1170,7 +1170,11 @@ class API(base_
ports = set(ports) - ports_to_skip
# Reset device_id and device_owner for the ports that are skipped ports(context, ports_to_skip, neutron) ports(context, ports_to_skip, neutron)
self. _delete_ ports(neutron, instance, ports, raise_if_fail=True)
- self._unbind_
+ # Only unbind port if neutron sees this port as bound
+ if data.get('ports', []):
+ self._unbind_
+ else:
+ LOG.debug("Skipping port unbind as neutron does not see any ports attached")
# Delete the rest of the ports