Provide hook feature for IMAGE management
|Category:||Core & System|
It would be really nice to have hook feature for the IMAGEs, as already provided for almost all other "objects".
One usecase we have is that we make a local copy of each image on the workers the first time and instance of this image is deployed on the worker, so that the next deployment will only need a snapshot. One missing feature there is to be able to delete the local copy on all workers when an image is deleted.
#1 Updated by Ruben S. Montero over 8 years ago
Although hooks for image management are definitively a very nice feature, the use case you describe should be address by customizing the TM scripts. These modifications should be at the tm level where the actual copy from the image repo to the host happens. It should be fairly straight forward to MD5 the source in tm_clone, check that a file with that MD5 is in a local directory in the DST and if so instead of scp o cp you can snapshot the disk file.
#3 Updated by Maxence Dunnewind over 8 years ago
There are 2 differents things :
- copy the image to the node the first time it is used on this host.
As you said, I implemented this in tm_clone.sh (based on image filename which is supposed to be unique).
- when an image is deleted from the pool (oneimage delete XX), delete it on all nodes
This is where hooks for images will be usefull. I may be wrong, but I don't think TM scripts are called when you delete an image. At the moment, the only way we have to remove deleted images on nodes is to run a cron script which lists the files in /var/lib/one/images, connect on each node and list the LVs, then remove those with no corresponding image existing.