Cannot copy snapshot to a new container using lxc copy in LXD 4.11

A container snapshot copy do not work with projects.

Did following and unable to create container.

$ lxc project create newproj -c features.profiles=false -c features.images=true -c features.storage.volumes=false
$ lxc launch test1 --project newproj
$ lxc snapshot test1 --project newproj
$ zfs list -t all | grep test1
local/containers/newproj_pm-test1@snapshot-snap0        1.81M      -     1.30G
$ lxc copy test1/snap0 test2 --project newproj
Error: Load source instance from database: 
Failed to fetch instance "test1/snap0" in project "default": No such object

It should have worked without any issues as it was working fine with default project but not with newly created project newproj. Storage pool ‘local’ is same for default and project test1.

Can you show:

  • lxd sql global "SELECT * FROM instances"
  • lxd sql global "SELECT * FROM instances_snapshots"
  • lxd sql global "SELECT * FROM storage_volumes"
  • lxd sql global "SELECT * FROM storage_volumes_snapshots"

Here are the results:

For first sql:
21 | 1 | test1 | 2 | 0 | 0 | 2021-02-08T17:29:45.334472462+01:00 | 0 | 2021-02-23T13:51:48.519354333+01:00 | | 2 | 0001-01-01T00:53:28+00:53 |

Second query:

±—±------------±------±------------------------------------±---------±------------±--------------------------+
| id | instance_id | name | creation_date | stateful | description | expiry_date |
±—±------------±------±------------------------------------±---------±------------±--------------------------+
| 14 | 21 | snap0 | 2021-02-23T13:54:03.306097512+01:00 | 0 | | 0001-01-01T00:53:28+00:53 |
±—±------------±------±------------------------------------±---------±------------±--------------------------+

Third query:
±—±-----------------------------------------------------------------±----------------±--------±-----±------------±-----------±-------------+
| id | name | storage_pool_id | node_id | type | description | project_id | content_type |
±—±-----------------------------------------------------------------±----------------±--------±-----±------------±-----------±-------------+
| 24 | test1 | 1 | 1 | 0 | | 2 | 0 |
±—±-----------------------------------------------------------------±----------------±--------±-----±------------±-----------±-------------+

Fourth query:

±—±------------------±------±------------±--------------------------+
| id | storage_volume_id | name | description | expiry_date |
±—±------------------±------±------------±--------------------------+
76 | 24 | snap0 | | 0001-01-01T00:53:28+00:53 |
±—±------------------±------±------------±--------------------------+

Can you pass --debug to the lxc copy and show the output?

DBUG[02-23|16:42:48] Sending request to LXD                   method=GET url="http://unix.socket/1.0/instances/test1/s
napshots/snap0?project=newproj" etag=
DBUG[02-23|16:42:48] Got response struct from LXD
DBUG[02-23|16:42:48]
        {
                "architecture": "x86_64",
                "config": {
                        "volatile.base_image": "34975ec2f95c139bb4b3751924448a7997b2626feb148d5e3c627bf401cc75e9",
                        "volatile.eth0.host_name": "veth5773cbe5",
                        "volatile.eth0.hwaddr": "00:16:3e:d2:de:0f",
                        "volatile.idmap.base": "0",
                        "volatile.idmap.current": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":
1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.idmap.next": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":100
0000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.idmap": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange
\":1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.power": "RUNNING",
                        "volatile.uuid": "87bb97a5-9e8b-4897-8367-55f65283aa5d"
                },
                "devices": {
                        "root": {
                                "path": "/",
                                "pool": "local",
                                "type": "disk"
                        }
                },
                "ephemeral": false,
                "profiles": [
                        "default"
                ],
                "expires_at": "0001-01-01T00:00:00Z",
                "created_at": "2021-02-23T13:54:03.306097512+01:00",
                "expanded_config": {
                        "volatile.base_image": "34975ec2f95c139bb4b3751924448a7997b2626feb148d5e3c627bf401cc75e9",
                        "volatile.eth0.host_name": "veth5773cbe5",
                        "volatile.eth0.hwaddr": "00:16:3e:d2:de:0f",
                        "volatile.idmap.base": "0",                                                                    [88/974]
                        "volatile.idmap.current": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":
1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.idmap.next": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":100
0000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.idmap": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange
\":1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.power": "RUNNING",
                        "volatile.uuid": "87bb97a5-9e8b-4897-8367-55f65283aa5d"
                },
                "expanded_devices": {
                        "eth0": {
                                "name": "eth0",
                                "network": "lxdfan0",
                                "type": "nic"
                        },
                        "root": {
                                "path": "/",
                                "pool": "local",
                                "type": "disk"
                        }
                },
                "last_used_at": "0001-01-01T00:00:00Z",
                "name": "snap0",
                "stateful": false,
                "size": 3254784
        }
DBUG[02-23|16:42:48] Sending request to LXD                   method=GET url="http://unix.socket/1.0/instances/test1?p
roject=newproj" etag=
DBUG[02-23|16:42:48] Got response struct from LXD
DBUG[02-23|16:42:48]
        {
                "architecture": "x86_64",
                "config": {
                        "volatile.base_image": "34975ec2f95c139bb4b3751924448a7997b2626feb148d5e3c627bf401cc75e9",
                        "volatile.eth0.host_name": "veth5773cbe5",
                        "volatile.eth0.hwaddr": "00:16:3e:d2:de:0f",
                        "volatile.idmap.base": "0",
                        "volatile.idmap.current": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":
1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.idmap.next": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":100
0000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.idmap": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange
\":1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.power": "RUNNING",
                        "volatile.uuid": "87bb97a5-9e8b-4897-8367-55f65283aa5d"
                },
                "devices": {
                        "root": {
                                "path": "/",
                                "pool": "local",
                                "type": "disk"
                        }
                },
                "ephemeral": false,
                "profiles": [
                        "default"
                ],
                "stateful": false,
                "description": "",
                "created_at": "2021-02-08T17:29:45.334472462+01:00",
                "expanded_config": {
                        "volatile.base_image": "34975ec2f95c139bb4b3751924448a7997b2626feb148d5e3c627bf401cc75e9",
                        "volatile.eth0.host_name": "veth5773cbe5",
                        "volatile.eth0.hwaddr": "00:16:3e:d2:de:0f",
                        "volatile.idmap.base": "0",
                        "volatile.idmap.current": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":
1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.idmap.next": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":100
0000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.idmap": "[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":1000000,\"Nsid\":0,\"Maprange
\":1000000000},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":1000000,\"Nsid\":0,\"Maprange\":1000000000}]",
                        "volatile.last_state.power": "RUNNING",
                        "volatile.uuid": "87bb97a5-9e8b-4897-8367-55f65283aa5d"
                },
                "expanded_devices": {
                        "eth0": {                                                                                      [12/974]
                                "name": "eth0",
                                "network": "lxdfan0",
                                "type": "nic"
                        },
                        "root": {
                                "path": "/",
                                "pool": "local",
                                "type": "disk"
                        }
                },
                "name": "test1",
                "status": "Running",
                "status_code": 103,
                "last_used_at": "2021-02-23T13:51:48.519354333+01:00",
                "location": "do-01",
                "type": "container"
        }
DBUG[02-23|16:42:48] Connected to the websocket: ws://unix.socket/1.0/events?project=newproj
DBUG[02-23|16:42:48] Sending request to LXD                   method=POST url="http://unix.socket/1.0/instances?project=newproj" $
tag=
DBUG[02-23|16:42:48]
        {
                "architecture": "x86_64",
                "config": {
                        "volatile.base_image": "34975ec2f95c139bb4b3751924448a7997b2626feb148d5e3c627bf401cc75e9"
                },
                "devices": {
                        "root": {
                                "path": "/",
                                "pool": "local",
                                "type": "disk"
                        }
                },
                "ephemeral": false,
                "profiles": [
                        "default"
                ],
                "stateful": false,
                "description": "",
                "name": "test2",
                "source": {
                        "type": "copy",
                        "certificate": "",
                        "base-image": "34975ec2f95c139bb4b3751924448a7997b2626feb148d5e3c627bf401cc75e9",
                        "source": "test1/snap0"
                },
                "instance_type": "",
                "type": ""
        }
Error: Load source instance from database: Failed to fetch instance "test1/snap0" in project "default": No such object

Thanks, I’ll take a look into it.