csi-digitalocean icon indicating copy to clipboard operation
csi-digitalocean copied to clipboard

Feature request: Support CSI PV Cloning

Open sandrotanner opened this issue 3 years ago • 5 comments

What did you do? (required. The issue will be closed when not provided.)

Try to clone a volume snapshot (CSI PV Cloning, see https://kubernetes-csi.github.io/docs/volume-cloning.html

What did you expect to happen?

That it was possible. Thanks in advance (see https://ideas.digitalocean.com/app-framework-services/p/doks-support-csi-pv-cloning for more info)

Configuration (MUST fill this out):

  • CSI Version: 4.0.0

sandrotanner avatar Jun 21 '22 12:06 sandrotanner

I think this is a reasonable request and something that could also be contributed externally.

timoreimann avatar Jul 07 '22 11:07 timoreimann

Thanks @timoreimann

I am not sure if it would be possible to contribute this externally. The reason for this is, that AFAIK we have no possibility to get information about the volume snapshot state/completion/progress (with droplet snapshots this was made possible a couple of years back, but the volume snapshots never followed). And I don't know if a implementation without first creating a snapshot and then basically doing https://github.com/digitalocean/csi-digitalocean/blob/e39d38ae6baeabef472f9945209b577f3283805b/driver/controller.go#L165 is possible.

Or maybe I am looking at it from the wrong angle (didn't do a whole lot of research yet tbh)? If it is possible I am gladly willing to contribute of course :)

sandrotanner avatar Jul 12 '22 08:07 sandrotanner

To be on the same page terminology-wise, what I think CSI cloning is about is the ability to create a volume from another volume. What DigitalOcean's CSI driver supports today already is creating a volume from an existing snapshot (which is called snapshot backup & restore). IMHO the CSI spec for CreateVolume makes the distinction more clear.

Looking at the Block Storage API, I think you're right that there is currently no support for copying/cloning a volume directly, and one would need to go via snapshotting a volume first. I don't think we'd need any progress indicator though as snapshots seem to be available immediately. (At least, there is no snapshot action available to be polled as we do on volumes.) This might be because snapshotting is done technically different than most volume actions unless the latency is not exposed and comes back as some kind of error. That's something to verify.

The perhaps bigger concern to me is the added complexity of having to create and restore from a snapshot, especially when considering what could go wrong and how to recover the right state. I'm thinking of things like the clone flow breaking in-between, and the CSI driver subsequently having to recover what needs to be done on a retry (i.e., determine if a snapshot has been created already or not). This is probably doable, but some effort would be required to get it right.

I'll talk to our Storage team to ensure my understanding of the level of cloning support is correct and get feedback on how this could be done with the current API.

timoreimann avatar Jul 25 '22 06:07 timoreimann

It looks like implementing this through snapshotting is the way to go for us.

timoreimann avatar Aug 08 '22 12:08 timoreimann

Would love to see this supported. I was hoping to use Kubernetes Stash's interimVolumeTemplate feature to clone a PVC by referencing it in the dataSource field, and then using the clone to create an off-site backup.

nielsvanoosterom-varias avatar Mar 06 '23 08:03 nielsvanoosterom-varias