Recursive delete of resources

Think I have seen a issue regarding this topic, but I can’t find it again, has there been added support for recursive delete, so it would be possible to delete a resource, and all it’s dependencies?

Can you give an example of such dependencies?

There was a recent discussion on storage volumes. If you attach a storage volume on a container and remove the container, the storage volume is not removed. Because a storage volume can stand by itself.

I ran into this topic yesterday.

So, one possible example would be completely removing Incus and the resources that were created with it, then reinstalling.

First, I needed to edit the default profile to remove the devices. Then I removed the network. Then all the resources in the storage pools. Then the storage pools. Then I purged the Incus package.

After that, I reinstalled the package and reinitialized Incus.

Most of the Incus side of things can be done with OpenTofu. This requires preplanning and a bit of discipline.

I have not found an easy way of doing it with the Incus CLI.

@jarrodu’s example, is pretty similar to my case, I have ran into the issue multiple times when developing on infrastructures, created with tools such as OpenTofu/Terraform. The only way to delete a resource manually with dependencies, is to delete all it’s dependencies. The solution I have thought of, would be similar to how the rm command works on Linux, with the -r flag.

So it was possible to do…

$ incus network rm -r some_network
$ incus profile rm -r some_profile

We have an issue open to allow forceful deletion of a project which will empty it of its content.

1 Like