canonical / multipass-blueprints

Blueprint definitions for [`multipass launch`](https://multipass.run)
GNU General Public License v3.0
70 stars 42 forks source link

Custom blueprints doesn't work #66

Open vilm725 opened 10 hours ago

vilm725 commented 10 hours ago

Hi everyone 👋🏻

I can't get the personal blueprints to work locally, even when put in my github repo (kde neon, ubuntu distrib 24.04 lts), despite forced update with multipass find --force-update and multipass find --only-blueprints. The multipass launch file://myblueprint command doesn't work with local blueprints either (see this article: https://discourse.ubuntu.com/t/doc-suggestion-how-to-use-custom-blueprints/42847).

However, my cloud-init files work fine, for example: multipass launch -n mydocker --cloud-init https://raw.githubusercontent.com/vilm725/multipass-blueprints/refs/heads/main/docker-custom.yml

I read the very short doc on the subject (https://github.com/canonical/multipass-blueprints?tab=readme-ov-file#testing) and saw that you have to modify the file /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf in order to make blueprints work. So I put a blueprint in my repo and another cloud init file to test them: https://github.com/vilm725/multipass-blueprints/

Here's what I've put in this file:

[Service]
Environment=MULTIPASS_STORAGE=/path/to/my/external/ssd/multipass/
Environment="MULTIPASS_BLUEPRINTS_URL=https://github.com/vilm725/multipass-blueprints/archive/refs/heads/main.zip"

Finally, I restarted multipass:

sudo snap restart multipass

When I search for my blueprints, I can't find anything:

$ multipass find --force-update
$ multipass find --only-blueprints
No blueprints found.
$ multipass launch customdocker
launch failed: Unable to find an image matching “customdocker” in remote “”.

So, please, how do you get blueprints to work? I confess I don't understand, the documentation is really minimal on this subject.

Sploder12 commented 5 hours ago

Hi @vilm725,

Sorry to hear things aren't working, I agree the documentation is minimal on this. For multipass launch file://<path>, double check you entered the path correctly. Otherwise, it could be an issue with the blueprint files or file permissions. An issue with the blueprints could also explain why find isn't finding the blueprints.

Looking at your blueprint files, I noticed a few issues that could be preventing it from working. One is the instance/blueprint name, you're using customdocker but the blueprint and instance name will be the filename without .yml. For example, for v1/docker-blueprint.yml it should be docker-blueprint. Also for your runs-on section, uncommenting x86_64 worked for me. The vendor-data section might give you issues, if it does, try removing it. This is because Multipass injects its own vendor-data section which might conflict with yours. Finally, your limits for memory and disk should probably have the G suffixes since they default to bytes without the suffix.

Looking at the layout of the zip, make sure all your blueprints are in the v1 folder, since Multipass will ignore them otherwise.

Let me know if trying this works! If it doesn't, would you be able to send your Multipass logs and the output of multipass launch file://<path>?

vilm725 commented 3 hours ago

Hi @Sploder12 👋🏻

First of all, THANK YOU SO MUCH for all your advice. I don't understand why your information isn't in the doc ...

I apologize if I got the names wrong. I had one version of the files on github and another locally in order to perform several tests. For this test, I decided to make a git clone to avoid filename errors and the like.

I've modify docker-blueprint.yml like this, the most minimal :

description: Custom docker # * a short description of the blueprint ("tagline")
version: latest          # * a version string

# multipass launch customdocker
# OU
# multipass launch customdocker --name docker-dev --cpus 4 --memory 8G --disk 50G

runs-on:                   # a list of architectures this blueprint can run on
# - arm64                    #   see https://doc.qt.io/qt-5/qsysinfo.html#currentCpuArchitecture
- x86_64                   #   for a list of valid values
- amd64

instances:
  customdocker:                  # * equal to the blueprint name
    image: 24.04    # a valid image alias, see `multipass find` for available values
    limits:
      min-cpu: 2       # the minimum number of CPUs this blueprint can work with
      min-mem: 4G    # the minimum amount of memory (can use G/K/M/B suffixes)
      min-disk: 20G   # and the minimum disk size (as above)
    #timeout: 1800         # maximum time for the instance to launch, and separately for cloud-init to complete
    cloud-init:
      vendor-data: |       # cloud-init vendor data

I've entered this command and, unlike usual, I don't get an immediate error, but rather 5 long minutes, only to get an time out error :

:~/Desktop/blueprints$ multipass launch https://raw.githubusercontent.com/vilm725/multipass-blueprints/refs/heads/main/v1/docker-blueprint.yml

launch failed: The following errors occurred:
devout-satyr: timed out waiting for response

:~$ multipass list 
Name                    State             IPv4             Image
dexterous-turnstone     Unknown           --               Not Available

After that command, multipass crash everytime :

# I restart mutlipass, 5 minutes ...
sudo snap restart multipass
[sudo] password for : 
2024-11-19T20:17:06+01:00 INFO Waiting for "snap.multipass.multipassd.service" to stop.
Run service command "restart" for running services of snap "multipass"

I've test file:// and I've test multipass launch with the name of the file without the yaml file extension but ... It doesn't work :

soso@soso:~/Desktop/multipass-blueprints/v1$ ls -la
total 12
drwxrwxr-x 2 soso soso 4096 nov.  19 20:39 .
drwxrwxr-x 4 soso soso 4096 nov.  19 20:39 ..
-rw-rw-r-- 1 soso soso 2147 nov.  19 20:39 docker-blueprint.yml

soso@soso:~/Desktop/multipass-blueprints/v1$ multipass launch docker-blueprint
launch failed: Unable to find an image matching "docker-blueprint" in remote "".

soso@soso:~/Desktop/multipass-blueprints/v1$ multipass launch docker-blueprint.yml
launch failed: Unable to find an image matching "docker-blueprint.yml" in remote "".

soso@soso:~/Desktop/multipass-blueprints/v1$ multipass launch file://docker-blueprint.yml
launch failed: There are no instance definitions matching Blueprint name "docker-blueprint"

soso@soso:~/Desktop/multipass-blueprints/v1$ multipass launch file://home/soso/Desktop/multipass-blueprints/v1/docker-blueprint.yml
launch failed: Wrong file '/home/soso/Desktop/multipass-blueprints/v1/home/soso/Desktop/multipass-blueprints/v1/docker-blueprint.yml'

This is the log file :

nov. 19 20:28:46 soso multipassd[157845]: Reading Blueprint 'blueprint-custom-docker' from file /home/soso/Desktop/blueprints/home/soso/Desktop/blueprints/blueprint-custom-docker.yml
nov. 19 20:28:53 soso multipassd[157845]: [159030] started: qemu-system-x86_64 --version
nov. 19 20:29:06 soso multipassd[157845]: [159118] started: qemu-system-x86_64 --version
nov. 19 20:29:06 soso multipassd[157845]: Reading Blueprint 'blueprint-custom-docker' from file /home/soso/Desktop/blueprints/blueprint-custom-docker.yml
nov. 19 20:29:13 soso multipassd[157845]: [159196] started: qemu-system-x86_64 --version
nov. 19 20:29:13 soso multipassd[157845]: Reading Blueprint 'blueprint-custom-docker' from file /home/soso/Desktop/blueprints/home/soso/Desktop/blueprints/blueprint-custom-docker.yml
nov. 19 20:31:23 soso multipassd[157845]: [159564] started: qemu-system-x86_64 --version
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159574] started: qemu-img info --output=json /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/cache/vault/images/docker-blueprint-/docker-blueprint.yml
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159579] started: qemu-img convert -p -O qcow2 /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/cache/vault/images/docker-blueprint-/docker-blueprint.yml /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/cache/vault/images/docker-blueprint-/docker-blueprint.yml.qcow2
nov. 19 20:31:24 soso multipassd[157845]: Failed to remove AppArmor policy 
                                          #include <tunables/global>
                                          profile multipass.qemu-img flags=(attach_disconnected) {
                                            #include <abstractions/base>

                                            capability ipc_lock,
                                            capability dac_read_search,

                                            # binary and its libs
                                            /snap/multipass/13373/usr/bin/qemu-img ixr,
                                            /snap/multipass/13373/{usr/,}lib/@{multiarch}/{,**/}*.so* rm,

                                            # CLASSIC ONLY: need to specify required libs from core snap
                                            /{,var/lib/snapd/}snap/core18/*/{,usr/}lib/@{multiarch}/{,**/}*.so* rm,

                                            # Images
                                            /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/cache/vault/images/docker-blueprint-/docker-blueprint.yml rwk,

                                            # Allow multipassd send qemu-img signals
                                            signal (receive) peer=snap.multipass.multipassd,
                                          }
                                              : errno=254 ()
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159588] started: qemu-img amend -o compat=1.1 /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/cache/vault/images/docker-blueprint-/docker-blueprint.yml.qcow2
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159595] started: qemu-img info /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/cache/vault/images/docker-blueprint-/docker-blueprint.yml.qcow2
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159603] started: qemu-img resize /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2 5368709120
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159610] started: qemu-img snapshot -l /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:31:24 soso multipassd[157845]: [159617] started: qemu-img amend -o compat=1.1 /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2
nov. 19 20:31:24 soso multipassd[157845]: process working dir '/snap/multipass/13373/qemu'
nov. 19 20:31:24 soso multipassd[157845]: process program 'qemu-system-x86_64'
nov. 19 20:31:24 soso multipassd[157845]: process arguments '-bios, OVMF.fd, --enable-kvm, -cpu, host, -nic, tap,ifname=tap-5a93cb7547c,script=no,downscript=no,model=virtio-net-pci,mac=52:54:00:b1:db:82, -device, virtio-scsi-pci,id=scsi0, -drive, file=/media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2,if=none,format=qcow2,discard=unmap,id=hda, -device, scsi-hd,drive=hda,bus=scsi0.0, -smp, 1, -m, 1024M, -qmp, stdio, -chardev, null,id=char0, -serial, chardev:char0, -nographic, -cdrom, /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/cloud-init-config.iso'
nov. 19 20:31:24 soso multipassd[157845]: [159648] started: qemu-system-x86_64 -nographic -dump-vmstate /tmp/multipassd.sTnnoF
nov. 19 20:31:24 soso multipassd[157845]: Applied AppArmor policy: multipass.dexterous-turnstone.qemu-system-x86_64
nov. 19 20:31:24 soso multipassd[157845]: process state changed to Starting
nov. 19 20:31:24 soso multipassd[157845]: process state changed to Running
nov. 19 20:31:24 soso multipassd[157845]: [159650] started: qemu-system-x86_64 -bios OVMF.fd --enable-kvm -cpu host -nic tap,ifname=tap-5a93cb7547c,script=no,downscript=no,model=virtio-net-pci,mac=52:54:00:b1:db:82 -device virtio-scsi-pci,id=scsi0 -drive file=/media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2,if=none,format=qcow2,discard=unmap,id=hda -device scsi-hd,drive=hda,bus=scsi0.0 -smp 1 -m 1024M -qmp stdio -chardev null,id=char0 -serial chardev:char0 -nographic -cdrom /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/cloud-init-config.iso
nov. 19 20:31:24 soso multipassd[157845]: process started
nov. 19 20:31:24 soso multipassd[157845]: Waiting for SSH to be up
nov. 19 20:41:54 soso multipassd[163027]: Loading "anbox-cloud-appliance" v1
nov. 19 20:41:54 soso multipassd[163027]: Loading "charm-dev" v1
nov. 19 20:41:54 soso multipassd[163027]: Loading "docker" v1
nov. 19 20:41:54 soso multipassd[163027]: Loading "jellyfin" v1
nov. 19 20:41:54 soso multipassd[163027]: Loading "minikube" v1
nov. 19 20:41:54 soso multipassd[163027]: Loading "ros2-humble" v1
nov. 19 20:41:54 soso multipassd[163027]: Loading "ros2-jazzy" v1
nov. 19 20:41:54 soso multipassd[163027]: gRPC listening on unix:/var/snap/multipass/common/multipass_socket
nov. 19 20:41:54 soso multipassd[163027]: fetch manifest periodically
nov. 19 20:41:54 soso multipassd[163027]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:41:54 soso multipassd[163027]: [163168] started: qemu-img snapshot -l /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2
nov. 19 20:41:54 soso multipassd[163027]: Applied AppArmor policy: multipass.qemu-img
nov. 19 20:41:54 soso multipassd[163027]: [163181] started: qemu-img amend -o compat=1.1 /media/soso/b24d9c94-c66c-4dec-9635-1bf2bd8bdeea/multipass/data/vault/instances/dexterous-turnstone/docker-blueprint.yml.qcow2
nov. 19 20:41:54 soso multipassd[163027]: Starting Multipass 1.14.1
nov. 19 20:41:54 soso multipassd[163027]: Daemon arguments: /snap/multipass/13373/bin/multipassd --verbosity debug --logger platform
nov. 19 20:51:03 soso multipassd[163027]: Loading "anbox-cloud-appliance" v1
nov. 19 20:51:03 soso multipassd[163027]: Loading "charm-dev" v1
nov. 19 20:51:03 soso multipassd[163027]: Loading "docker" v1
nov. 19 20:51:03 soso multipassd[163027]: Loading "jellyfin" v1
nov. 19 20:51:03 soso multipassd[163027]: Loading "minikube" v1
nov. 19 20:51:03 soso multipassd[163027]: Loading "ros2-humble" v1
nov. 19 20:51:03 soso multipassd[163027]: Loading "ros2-jazzy" v1
nov. 19 20:51:03 soso multipassd[163027]: [164592] started: qemu-system-x86_64 --version
nov. 19 20:51:03 soso multipassd[163027]: Reading Blueprint 'docker-blueprint' from file /home/soso/Desktop/multipass-blueprints/v1/docker-blueprint.yml
nov. 19 20:51:50 soso multipassd[163027]: [164752] started: qemu-system-x86_64 --version
nov. 19 20:51:50 soso multipassd[163027]: Reading Blueprint 'docker-blueprint' from file /home/soso/Desktop/multipass-blueprints/v1/home/soso/Desktop/multipass-blueprints/v1/docker-blueprint.yml
nov. 19 20:56:54 soso multipassd[163027]: fetch manifest periodically
nov. 19 21:00:50 soso multipassd[163027]: Loading "anbox-cloud-appliance" v1
nov. 19 21:00:50 soso multipassd[163027]: Loading "charm-dev" v1
nov. 19 21:00:50 soso multipassd[163027]: Loading "docker" v1
nov. 19 21:00:50 soso multipassd[163027]: Loading "jellyfin" v1
nov. 19 21:00:50 soso multipassd[163027]: Loading "minikube" v1
nov. 19 21:00:50 soso multipassd[163027]: Loading "ros2-humble" v1
nov. 19 21:00:50 soso multipassd[163027]: Loading "ros2-jazzy" v1
nov. 19 21:00:50 soso multipassd[163027]: [165719] started: qemu-system-x86_64 --version
nov. 19 21:00:50 soso multipassd[163027]: Reading Blueprint 'docker-blueprint' from file /home/soso/Desktop/multipass-blueprints/v1/home/soso/Desktop/multipass-blueprints/v1/docker-blueprint.yml
nov. 19 21:00:55 soso multipassd[163027]: [165792] started: qemu-system-x86_64 --version
nov. 19 21:00:55 soso multipassd[163027]: Reading Blueprint 'docker-blueprint' from file /home/soso/Desktop/multipass-blueprints/v1/docker-blueprint.yml

To sum up, there's only this command multipass launch https://raw.githubusercontent.com/vilm725/multipass-blueprints/refs/heads/main/v1/docker-blueprint.yml that “loads” for 5 minutes but ends with an timeout error, whereas before it stopped immediately.

Honestly, I don't understand why it doesn't work. The log file above doesn't describe any glaring errors ... Do you have any idea?

Full log file : multipass-log.txt

Sploder12 commented 1 hour ago

Thank you for providing so much detail @vilm725!

Blueprints can take a long time to load so I recommend setting a long timeout, but this appears to be a more interesting issue. Could you try modifying line 14 of docker-blueprint.yml like so? If that doesn't work, try also removing vendor-data and cloud-init entirely. This could be a bug in how we handle instance names.

- customdocker:                  # * equal to the blueprint name
+ docker-blueprint:              # * equal to the blueprint name

If Multipass crashes badly, restarting your machine will get it back to normal. You can also try sending SIGKILL to any hanging Multipass processes, but beware of potential data loss.