Thanks for confirming. The reason why I asked this question is due to VM deletion. By default, deleting a VM instance means its single openstack port associated with the VM (created automatically by nova), would be auto deleted, there's no extra work needed for that; But if the associated openstack port was manually created for this VM instance, then it seems it would NOT remove this openstack port automatically. I would like to ensure the cleanup of such ports upon VM deletion. There's connection.network.delete_port() function from openstacksdk, and I could retrieve all associated ports for a particular vm instance, so it is possible to just delete all associated ports for the instance upon VM deletion call, but there might be some conflicts, meaning that for ports auto created by nova, those will be purged by openstack automatically. How to ensure there would be no conflicts upon vm deletion call, and ensure all associated ports would be purged without error? On Thu, Jan 5, 2023 at 6:32 AM Sean Mooney <smooney@redhat.com> wrote:
On Thu, 2023-01-05 at 10:08 +0100, Slawek Kaplonski wrote:
Hi,
Dnia czwartek, 5 stycznia 2023 03:54:25 CET hai wu pisze:
I could not find any API way to tell the difference between openstack ports created automatically when a new instance got created, and openstack ports manually created for port reservation purposes.
There's 'preserve_on_delete' attribute in the openstack database for each vm instance, and if it is set to 'true', then the port was manually created, if not, then it was automatically created. But there's no API to retrieve this.
Am I missing something?
Hai
You are no missing anything. There is no way to check that using API (both Neutron nor Nova). ya i think you can tell from the nova db if it was created by nova by corralating the virutal interface table and request spec for the instance but its not somethign you can tell form the api or form neutron's perspective.
there are some cases where preserve_on_delete can be lost too. namely if neutron breaks and the network info cache is currpted and teh ports are removed form the cache when the cache is forcefully rebuilt the value of preserve_on_delete may not be preserved. https://bugs.launchpad.net/nova/+bug/1834463 we also have https://bugs.launchpad.net/nova/+bug/1976545 one of the possible fixes for the later https://review.opendev.org/c/openstack/nova/+/844326 would ideally involve a new neutron api extention to model delete_on_detach
im not sure if that is related to why you asked this question? can you expalin why you are trying to determin if it was manually created vs created by nova?