> In testing the patch I proposed, it seems to help but we still seem to orphan some ports
We create an 'internal port' for the new instances only if a 'subnet' is specified[1] before making calls to nova. So if nova fails to schedule an instance subsequently the port is left behind. However it would be deleted, when heat deletes that instance or replaces the instance after your patch. So there should be as many number of orphaned ports as the number of FAILED instances, which should be fine IMO.
The only drawback/inefficiency with your patch is that we would create a new internal port every time when replacing an instance, irrespective of the fact that nothing has changed for the servers networks property and the server may be get a different ip (unless fixed_ip is specified)
Ideally we should have been able to attach the existing port to the new instance. Though I think it would be complicated as we also have to check if the subnet has changed and we need a new internal port instead.
> In testing the patch I proposed, it seems to help but we still seem to orphan some ports
We create an 'internal port' for the new instances only if a 'subnet' is specified[1] before making calls to nova. So if nova fails to schedule an instance subsequently the port is left behind. However it would be deleted, when heat deletes that instance or replaces the instance after your patch. So there should be as many number of orphaned ports as the number of FAILED instances, which should be fine IMO.
The only drawback/ inefficiency with your patch is that we would create a new internal port every time when replacing an instance, irrespective of the fact that nothing has changed for the servers networks property and the server may be get a different ip (unless fixed_ip is specified)
Ideally we should have been able to attach the existing port to the new instance. Though I think it would be complicated as we also have to check if the subnet has changed and we need a new internal port instead.
[1] https:/ /github. com/openstack/ heat/blob/ master/ heat/engine/ resources/ openstack/ nova/server_ network_ mixin.py# L234