How to recover longhorn volume metadata after reinstall

I have a question about the general concept how longhorn is managing the metadata for disks/volumes

I observed, that after I uninstall longhorn (with the uninstall.yaml) and than reinstall it, my manual created volumes are lost.
This surprises me a little, because I assume that Longhorn does not delete/erase the hard disks located in the path /var/lib/longhorn/ for each node?

Is there a way how longhorn can recognize old data on the attached disks an reuse that data?

Thank you if anyone can help me here.

===
Ralph

Hi @rsoika

In fact Longhorn did erase all the data on the disk when it’s uninstalled. There might be some leftovers due to clean up failure sometime, but it’s basically “rm -rf”.

But does this mean that you “rm -rf” the node volumes? Or just meta data? Can I avoid the “rm -rf”?
Ok I must agree that the use case is somehow curious - why should I want to delete longhorn but don’t want to delete ‘longhorn’…

But I think about the following:
I have a data volume created with important business data. Than for some reason I need to setup my complete cluster and I rebound my disks (with the important data). But now because of the deletion of the Longhorn services also my important data was deleted. I would think it is better to let the data on the disks as it was and it’s up to the cluster administrator if she wants to wipe out the disks too.

Is that understandable what I want to say?

Yeah it will delete the data on the node as well.

Even only deleting the metadata, it will result Longhorn unable to find the data once reinstalled, since the metadata that Longhorn stored in Kubernetes API server (in the form of CRDs) keep the location of the volume as well as the configuration of Longhorn.

Currently Longhorn consider “uninstalling” means you don’t want to use Longhorn. So as parts of Longhorn, the data and metadata will be cleaned up when you uninstalled as well.

I understand your concern, but it’s normally the admin who decided to uninstall Longhorn. I think it will make things more complicated if uninstallation doesn’t clean up the data. There might be complains that why Longhorn leftover data on the disk and CRDs then…

For the important data, we do suggest to back it up using e.g. Longhorn backup mechanism, or backup the disk as whole. That’s the most secure way to prevent the data loss.