Skip to content

Clone a resource definition and all its snapshots #439

@luissimas

Description

@luissimas

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 ┊
╰────────────────────────────────────────────────────────────────────────────────────────────────╯

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions