ansible-community/molecule-hetznercloud

Volume clean up does not delete attached volumes

Closed this issue · 13 comments

xoxys commented

Pretty sure it is expected to not auto delete the volume as it can be reused and attached to a different server. Maybe some kind of fore option is possible.

xoxys commented

Wait my fault... You were talking about the hcloud_volume module... In this case, I agree
:D

Yeah I guess for the testing use case, you want to tear down all resources afterwards.

Let's see what comes out of that ticket upstream.

OK, looks like it is on our end, need to investigate:

ansible-collections/hetzner.hcloud#47 (comment)

xoxys commented

I'm a bit confused as I'm using this construct since a while with the delegated driver in molecule without issues. As the servers were deleted first volumes should be unattached already if the hetzner_volume absent task is running.

Hmmmm yeah weird...best reply as response to ansible-collections/hetzner.hcloud#47 (comment)?

Don't have time to dig into this right now...

As i wrote in the initial issue, i think the problem is that the state is not correct to set to absent. I say present, otherwise, it would go through the "detaching" step.

Hi guys,
I am having a similar issue right now. When I run molecule destroy, i get msg: volume with ID 'XXXXXX' is still attached to a server. I really want to delete the Volume in my case. But it does not even get detached correctly - it seems because the instances got deleted already. In the end, all instances are gone, but Volume is (even if detached), still existant.

So if we want to destroy molecule instances, should the workflow not be the other way around?

  1. delete volumes
  2. delete instances

This way, the volumes would really be deleted, if no delete_protection is enabled. Then there would also be no message about Volume being attached to the server. By the way - I have not yet checked the full code of the Plugin! So if I am completely wrong, I am sorry. But basically i can not destroy my instances due to the fact its still attached.

Regards

Hmmm, it seems like we need to first then detach the volumes, delete the instances and then run the delete of the volumes again to finally fully delete them (EDIT: tested, this doesn't work). It seems the current logic of first deleting the instance with the still attached volumes (it is actually working for me but I see not for @cwaninger) is getting the volumes into a weird state!? Good point regard delete_protection, we should ensure that is disabled for testing runs. I will try to fix this shortly.

I don't quite understand your comments in #24 (comment) @LKaemmerling, are you referring to https://github.com/ansible-community/molecule-hetznercloud/blob/main/molecule_hetznercloud/playbooks/destroy.yml? Because I don't see how setting that to present would help? Also re: ansible-collections/hetzner.hcloud#47 (comment) the server is not empty and the volume is technically not still attached since the instance is first deleted? I will take another look. It still feels like there is a bug in here somewhere.

Ok, the saga continues but ansible-collections/hetzner.hcloud#47 (comment) happened! So it looks like this is something that will help when we can move to the new version. I am still stuck for time but I if anyone has spoons, this could be fixable now.