linstor-server icon indicating copy to clipboard operation
linstor-server copied to clipboard

Clone a resource definition and all its snapshots

Open luissimas opened this issue 10 months ago • 2 comments

Hello folks!

We're currently implementing a LINSTOR driver for Incus, and one of the requirements is to copy volumes and instances with their respective snapshots.

We've been using the clone operation to achieve the copying of resource definitions but, as far as I know, this operation does not copy the snapshots for the resources. How could we achieve the copying of a resource definition with all its snapshots in LINSTOR?

To illustrate the desired behavior, consider the current behavior:

root@server01 ~# linstor rg spawn demo test 1GiB
...
root@server01 ~ [2]# linstor s create test snap1
...
root@server01 ~# linstor rd l
╭────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Port ┊ ResourceGroup ┊ Layers       ┊ State ┊
╞════════════════════════════════════════════════════════════╡
┊ test         ┊ 7000 ┊ demo          ┊ DRBD,STORAGE ┊ ok    ┊
╰────────────────────────────────────────────────────────────╯
root@server01 ~# linstor s l
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ SnapshotName ┊ NodeNames          ┊ Volumes  ┊ CreatedOn           ┊ State      ┊
╞════════════════════════════════════════════════════════════════════════════════════════════════╡
┊ test         ┊ snap1        ┊ server01, server02 ┊ 0: 1 GiB ┊ 2025-02-26 18:07:08 ┊ Successful ┊
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
root@server01 ~ [2]# linstor rd clone test test-clone
...
Waiting for cloning to complete...
Completed cloning test-clone.
root@server01 ~# linstor rd l
╭────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Port ┊ ResourceGroup ┊ Layers       ┊ State ┊
╞════════════════════════════════════════════════════════════╡
┊ test         ┊ 7000 ┊ demo          ┊ DRBD,STORAGE ┊ ok    ┊
┊ test-clone   ┊ 7001 ┊ demo          ┊ DRBD,STORAGE ┊ ok    ┊
╰────────────────────────────────────────────────────────────╯
root@server01 ~# linstor s l
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ SnapshotName ┊ NodeNames          ┊ Volumes  ┊ CreatedOn           ┊ State      ┊
╞════════════════════════════════════════════════════════════════════════════════════════════════╡
┊ test         ┊ snap1        ┊ server01, server02 ┊ 0: 1 GiB ┊ 2025-02-26 18:07:08 ┊ Successful ┊
╰────────────────────────────────────────────────────────────────────────────────────────────────╯

As you can see, at the end of the operations there's only one snapshot: snap1 for resource test.

I'd like to achieve a result with the following state, in which the new resource definition test-clone also has any previous snapshots that were created for the original test resources:

root@server01 ~# linstor rd l
╭────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Port ┊ ResourceGroup ┊ Layers       ┊ State ┊
╞════════════════════════════════════════════════════════════╡
┊ test         ┊ 7000 ┊ demo          ┊ DRBD,STORAGE ┊ ok    ┊
┊ test-clone   ┊ 7001 ┊ demo          ┊ DRBD,STORAGE ┊ ok    ┊
╰────────────────────────────────────────────────────────────╯
root@server01 ~# linstor s l
╭────────────────────────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ SnapshotName ┊ NodeNames          ┊ Volumes  ┊ CreatedOn           ┊ State      ┊
╞════════════════════════════════════════════════════════════════════════════════════════════════╡
┊ test         ┊ snap1        ┊ server01, server02 ┊ 0: 1 GiB ┊ 2025-02-26 18:07:08 ┊ Successful ┊
┊ test-clone   ┊ snap1        ┊ server01, server02 ┊ 0: 1 GiB ┊ 2025-02-26 18:07:24 ┊ Successful ┊
╰────────────────────────────────────────────────────────────────────────────────────────────────╯

luissimas avatar Feb 26 '25 18:02 luissimas

Currently, only if you do a manual clone. And then you will probably realize why this isn't so easy to do at all if you try more advanced clones with encrypted volumes or layer-stack changes between clones.

So this is no feature that would come in the near future to Linstor or maybe ever.

rp- avatar Feb 27 '25 07:02 rp-

Ok, that makes sense.

What would a "manual clone" in this scenario look like? One of the ways I thought about doing this operation was to restore the snapshots into the new resource definition and then create snapshots after each restoration to essentially replicate all snapshots. To do the final copying of the current state of the resource I'd probably just take a temporary snapshot of the original resource and then do a final restore on the target resource definition.

luissimas avatar Feb 28 '25 15:02 luissimas