Unexpected behaviour with lxc image copy --copy-alises

,

local aliases are unique to an image, not an image of an image-type?

TL;DR
Am I correct, or am I incorrect, that the aliases should be copied to the local storage, and should not be unique across instance types? That is to say, both a VM and Container image should be able to have the jammy or noble alias.

Acquring the images: order 1

Issuing

lxc image copy ubuntu:jammy local: --copy-aliases
lxc image copy ubuntu:jammy local: --copy-aliases --vm
lxc image copy ubuntu:noble local: --copy-aliases
lxc image copy ubuntu:noble local: --copy-aliases --vm

I see the following images are stored:

+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|   ALIAS    | FINGERPRINT  | PUBLIC |                 DESCRIPTION                 | ARCHITECTURE |      TYPE       |   SIZE    |          UPLOAD DATE          |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| j (5 more) | d45dfeba51e0 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 592.69MiB | Aug 26, 2024 at 4:19pm (UTC)  |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| n (9 more) | 042aedb75f54 | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 558.88MiB | Aug 27, 2024 at 3:32pm (UTC)  |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|            | a3a811814328 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 413.98MiB | Aug 25, 2024 at 10:47am (UTC) |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|            | f0fbf5affa6a | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 241.13MiB | Aug 27, 2024 at 11:10am (UTC) |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+

Notice that the alias is set for the VMs, which are the second of the container/ VM aquisitions.

Acquring the images: order 2

If I switch the order of the Jammy container & VM acquisition, having already executed the previous command:

lxc image copy ubuntu:jammy local: --copy-aliases --vm
lxc image copy ubuntu:jammy local: --copy-aliases
lxc image copy ubuntu:noble local: --copy-aliases
lxc image copy ubuntu:noble local: --copy-aliases --vm

I see this:

+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|   ALIAS    | FINGERPRINT  | PUBLIC |                 DESCRIPTION                 | ARCHITECTURE |      TYPE       |   SIZE    |          UPLOAD DATE          |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| j (5 more) | a3a811814328 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 413.98MiB | Aug 25, 2024 at 10:47am (UTC) |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| n (9 more) | 042aedb75f54 | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 558.88MiB | Aug 27, 2024 at 3:32pm (UTC)  |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|            | d45dfeba51e0 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 592.69MiB | Aug 26, 2024 at 4:19pm (UTC)  |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|            | f0fbf5affa6a | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 241.13MiB | Aug 27, 2024 at 11:10am (UTC) |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+

The Jammy container image, which was acquired after the Jammy VM image, owns the alias.

Observation vs expectation

The aliases are not copied and preserved for each image, they seem to be required to one image, irrespective of image type.
I expected each image to retain its aliases, and the --vm switch to be used as a way to discerne between the container and VMs images.

We can see the aliases exist on the remote:

$ lxc image info ubuntu:jammy

Fingerprint: a3a8118143289e285ec44b489fb1a0811da75c27a22004f7cd34db70a60a0af4
Size: 413.98MiB
Architecture: x86_64
Type: container
Public: yes
Timestamps:
    Created: 2024/08/21 00:00 UTC
    Uploaded: 2024/08/21 00:00 UTC
    Expires: 2027/06/01 00:00 UTC
    Last used: never
Properties:
    serial: 20240821
    description: ubuntu 22.04 LTS amd64 (release) (20240821)
    type: squashfs
    os: ubuntu
    release: jammy
    version: 22.04
    architecture: amd64
    label: release
Aliases:
    - 22.04
    - 22.04/amd64
    - j
    - j/amd64
    - jammy
    - jammy/amd64
Cached: no
Auto update: disabled
Profiles: []
$ lxc image info ubuntu:jammy --vm

Fingerprint: d45dfeba51e0008dbd0bb0828a2684b54274aabde43bbf9fa4db68d2bd97813e
Size: 592.69MiB
Architecture: x86_64
Type: virtual-machine
Public: yes
Timestamps:
    Created: 2024/08/21 00:00 UTC
    Uploaded: 2024/08/21 00:00 UTC
    Expires: 2027/06/01 00:00 UTC
    Last used: never
Properties:
    serial: 20240821
    description: ubuntu 22.04 LTS amd64 (release) (20240821)
    type: disk-kvm.img
    os: ubuntu
    release: jammy
    version: 22.04
    architecture: amd64
    label: release
Aliases:
    - 22.04
    - 22.04/amd64
    - j
    - j/amd64
    - jammy
    - jammy/amd64
Cached: no
Auto update: disabled
Profiles: []
$ lxc image info ubuntu:noble 

Fingerprint: f0fbf5affa6a3c22848f24ba304525354023fdc33f4390aa816ae05bdb94dbe9
Size: 241.13MiB
Architecture: x86_64
Type: container
Public: yes
Timestamps:
    Created: 2024/08/21 00:00 UTC
    Uploaded: 2024/08/21 00:00 UTC
    Expires: 2029/05/31 00:00 UTC
    Last used: never
Properties:
    serial: 20240821
    description: ubuntu 24.04 LTS amd64 (release) (20240821)
    type: squashfs
    os: ubuntu
    release: noble
    version: 24.04
    architecture: amd64
    label: release
Aliases:
    - 24.04
    - 24.04/amd64
    - n
    - n/amd64
    - noble
    - noble/amd64
    - lts
    - lts/amd64
    - default
    - default/amd64
Cached: no
Auto update: disabled
Profiles: []
$ lxc image info ubuntu:noble --vm

Fingerprint: 042aedb75f54341bc8e16f737e2acec7a1561b1dfd4502cb09398a4a36549eb7
Size: 558.88MiB
Architecture: x86_64
Type: virtual-machine
Public: yes
Timestamps:
    Created: 2024/08/21 00:00 UTC
    Uploaded: 2024/08/21 00:00 UTC
    Expires: 2029/05/31 00:00 UTC
    Last used: never
Properties:
    os: ubuntu
    release: noble
    version: 24.04
    architecture: amd64
    label: release
    serial: 20240821
    description: ubuntu 24.04 LTS amd64 (release) (20240821)
    type: disk1.img
Aliases:
    - 24.04
    - 24.04/amd64
    - n
    - n/amd64
    - noble
    - noble/amd64
    - lts
    - lts/amd64
    - default
    - default/amd64
Cached: no
Auto update: disabled
Profiles: []

Attempting to set local aliases

If I attempt to add an alias to the local copy of the Jammy container, I am informed the Jammy alias already exists, which leads me to believe the alias must be, as previously noted, unique to a single image irrespective of the image type.

$ lxc image alias create jammy a3a811814328

Error: Alias "jammy" already exists

$ lxc image list
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|   ALIAS    | FINGERPRINT  | PUBLIC |                 DESCRIPTION                 | ARCHITECTURE |      TYPE       |   SIZE    |          UPLOAD DATE          |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| j (5 more) | d45dfeba51e0 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 592.69MiB | Aug 26, 2024 at 4:19pm (UTC)  |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| n (9 more) | 042aedb75f54 | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 558.88MiB | Aug 27, 2024 at 3:32pm (UTC)  |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|            | a3a811814328 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 413.98MiB | Aug 25, 2024 at 10:47am (UTC) |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|            | f0fbf5affa6a | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 241.13MiB | Aug 27, 2024 at 11:10am (UTC) |
+------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+

I can set up my own aliases which correctly categorize the images:

$ lxc image alias create local:jammy-ctr a3a811814328
$ lxc image alias create local:jammy-vm  d45dfeba51e0
$ lxc image alias create local:noble-ctr f0fbf5affa6a
$ lxc image alias create local:noble-vm  042aedb75f54
$ lxc image list

+-------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
|    ALIAS    | FINGERPRINT  | PUBLIC |                 DESCRIPTION                 | ARCHITECTURE |      TYPE       |   SIZE    |          UPLOAD DATE          |
+-------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| j (6 more)  | d45dfeba51e0 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 592.69MiB | Aug 26, 2024 at 4:19pm (UTC)  |
+-------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| jammy-ctr   | a3a811814328 | no     | ubuntu 22.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 413.98MiB | Aug 25, 2024 at 10:47am (UTC) |
+-------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| n (10 more) | 042aedb75f54 | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | VIRTUAL-MACHINE | 558.88MiB | Aug 27, 2024 at 3:32pm (UTC)  |
+-------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+
| noble-ctr   | f0fbf5affa6a | no     | ubuntu 24.04 LTS amd64 (release) (20240821) | x86_64       | CONTAINER       | 241.13MiB | Aug 27, 2024 at 11:10am (UTC) |
+-------------+--------------+--------+---------------------------------------------+--------------+-----------------+-----------+-------------------------------+

Summary

Am I correct, or am I incorrect, that the aliases should be copied to the local storage, and should not be unique across instance types? That is to say, should both a VM and Container image be able to have the jammy or noble alias when stored locally?

Hi! Sorry for the delay on the response.
I managed to reproduce your problem and I agree with your interpretation. This behavior may very well be undesirable.

Would you mind opening an issue under https://github.com/canonical/lxd/issues/new and include this information so we can investigate this in more depth?

1 Like

Thank you for your response @pedro-rib , I’m pleased you agree with my train of thought.

I’ve opened an issue :slightly_smiling_face:

1 Like