openmainframeproject / feilong

Feilong is a open source z/VM cloud connector project under the Open Mainframe Project umbrella that will accelerate the z/VM adoption, extending its ecosystem and its user experience. It provides a set of APIs to operate z/VM including guest, image, network, volume etc.
https://www.openmainframeproject.org/projects/feilong
Apache License 2.0
36 stars 70 forks source link

Reset FCP assignements of deleted VM #845

Open Bischoff opened 1 week ago

Bischoff commented 1 week ago

PLEASE DO NOT MERGE IMMEDIATELY

This PR was tested to work, but I'd like expert advice before merging it. My code might be very naive, or even incorrect.


With current code when you:

  1. create a VM guest
  2. attach a disk via AttachVolume() to that guest
  3. forget to detach it via DetachVolume()
  4. delete the instance

then the disk stays counted as attached to the deleted instance.

If you recreate the instance, then AttachVolume() will skip the dedication, because it considers that the disk is already dedicated to the instance, while it is not.

This PR resets the FCP records in database for the deleted instance at time of deletion.