canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 446 forks source link

Error 2 on snapcraft on linux with multipass: #4106

Closed talregev closed 1 year ago

talregev commented 1 year ago

Please log issues on the project's bug tracker

Alternatively, If you are looking for support, try posting on the forums

I found my issue here: https://askubuntu.com/questions/1460377/launch-failed-remote-snapcraft-is-unknown-or-unreachable-multipass-returned and similar here: https://forum.snapcraft.io/t/an-error-occurred-with-the-instance-when-trying-to-launch-with-multipass-returned-exit-code-2-ensure-that-multipass-is-setup-correctly-and-try-again/30155/3

I get an error while run the snapcraft with multipass:

The error is come that snapcraft doesn't give the correct image name. I didn't sure if you meant to core22 or 22.04 both images are in multipass. I have a workaround, to create the image with snapcraft chosen name and 22.04 image:

multipass launch 22.04 --name snapcraft-boinc-on-amd64-for-amd64-33569008 --cpus 2 --mem 2G --disk 64G

The error before the workaround:

> snapcraft --verbosity verbose pack --build-for amd64
Starting Snapcraft 7.3.1
Logging execution to '/home/tal/.local/state/snapcraft/log/snapcraft-20230419-042442.656224.log'
Running on amd64 for amd64
Launching instance... | (4.6s)                                                                                                                 Traceback (most recent call last):
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/multipass/multipass.py", line 183, in launch
    self._run(command)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/multipass/multipass.py", line 66, in _run
    return subprocess.run(command, check=True, capture_output=True, **kwargs)
  File "/snap/snapcraft/8931/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['multipass', 'launch', 'snapcraft:22.04', '--name', 'snapcraft-boinc-on-amd64-for-amd64-33569008', '--cpus', '2', '--mem', '2G', '--disk', '64G']' returned non-zero exit status 2.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/8931/bin/snapcraft", line 8, in <module>
    sys.exit(run())
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/cli.py", line 243, in run
    _run_dispatcher(dispatcher)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/cli.py", line 219, in _run_dispatcher
    dispatcher.run()
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
    return self._loaded_command.run(self._parsed_command_args)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 259, in run
    super().run(parsed_args)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 132, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 215, in run
    _run_command(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 256, in _run_command
    _run_in_provider(project, command_name, parsed_args)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 540, in _run_in_provider
    with provider.launched_environment(
  File "/snap/snapcraft/8931/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/multipass/multipass_provider.py", line 105, in launched_environment
    instance = launch(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/multipass/_launch.py", line 76, in launch
    instance.launch(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/multipass/multipass_instance.py", line 309, in launch
    self._multipass.launch(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/multipass/multipass.py", line 185, in launch
    raise MultipassError(
craft_providers.multipass.errors.MultipassError: Failed to launch VM 'snapcraft-boinc-on-amd64-for-amd64-33569008'.
* Command that failed: 'multipass launch snapcraft:22.04 --name snapcraft-boinc-on-amd64-for-amd64-33569008 --cpus 2 --mem 2G --disk 64G'
* Command exit code: 2
* Command output: b'warning: "--mem" long option will be deprecated in favour of "--memory" in a future release.Please update any scripts, etc.\n\r
* Command standard error output: b'launch failed: Remote "snapcraft" is unknown or unreachable.\n'
mr-cal commented 1 year ago

Hi, thanks for the bug report!

Can you reproduce this issue directly from the command line, using multipass launch snapcraft:core22?

I can reproduce this same failure by:

  1. disconnecting network
  2. snap restart multipass
  3. multipass launch snapcraft:core22 gives launch failed: Remote "snapcraft" is unknown or unreachable.

If you can reproduce from the command line, I suggest you open an issue with Multipass.

We have an issue here to improve the user experience for when this occurs.

talregev commented 1 year ago

Why you disconnected your network? This issue is happening always with the network on. You can type the command that snapcraft send to multipass and see the error again: wrong command:

multipass launch snapcraft:22.04 --name snapcraft-boinc-on-amd64-for-amd64-33569008 --cpus 2 --mem 2G --disk 64G

correct command:

multipass launch 22.04 --name snapcraft-boinc-on-amd64-for-amd64-33569008 --cpus 2 --mem 2G --disk 64G

This is a bug from snapcraft because it give the wrong command to multipass. When I do the workaround and give the correct command to multipass and the instance is created, snapcraft continue regular and successful build the snap inside multipass.

mr-cal commented 1 year ago

Why you disconnected your network?

Good question! It's the only way I've been able to reproduce this failure. I don't have a root cause, but the common pattern across reports involves network connectivity with the buildd image server. For example, the askubuntu question you mentioned has logs about multipass not having network access from inside the snap.

This is a bug from snapcraft because it give the wrong command to multipass.

I can confirm that snapcraft is using the correct image when it calls multipass launch snapcraft:22.04. snapcraft:22.04 and 22.04 are different images.

Can you reproduce this issue directly from the command line, using multipass launch snapcraft:core22?

talregev commented 1 year ago

when I type to multipass this image snapcraft:core22 I received the same error. I also type to multipass list of all images and there isn't a snapcraft:22:04 nor snapcraft:core22 images. What is your version of multipass? Is it the latest?

talregev commented 1 year ago

Can you show me the list of all the images of multipass?

mr-cal commented 1 year ago

On a "good day", multipass find should show:

Image                       Aliases           Version          Description
snapcraft:core18            18.04             20201111         Snapcraft builder for Core 18
snapcraft:core20            20.04             20210921         Snapcraft builder for Core 20
snapcraft:core22            22.04             20220426         Snapcraft builder for Core 22
snapcraft:devel                               20230418         Snapcraft builder for the devel series
core                        core16            20200818         Ubuntu Core 16
core18                                        20211124         Ubuntu Core 18
core20                                        20230119         Ubuntu Core 20
core22                                        20230119         Ubuntu Core 22
18.04                       bionic            20230329         Ubuntu 18.04 LTS
20.04                       focal             20230209         Ubuntu 20.04 LTS
22.04                       jammy,lts         20230416         Ubuntu 22.04 LTS
22.10                       kinetic           20230418         Ubuntu 22.10
appliance:adguard-home                        20200812         Ubuntu AdGuard Home Appliance
appliance:mosquitto                           20200812         Ubuntu Mosquitto Appliance
appliance:nextcloud                           20200812         Ubuntu Nextcloud Appliance
appliance:openhab                             20200812         Ubuntu openHAB Home Appliance
appliance:plexmediaserver                     20200812         Ubuntu Plex Media Server Appliance
anbox-cloud-appliance                         latest           Anbox Cloud Appliance
charm-dev                                     latest           A development and testing environment for charmers
docker                                        0.4              A Docker environment with Portainer and related tools
jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube                                      latest           minikube is local Kubernetes
ros-noetic                                    0.1              A development and testing environment for ROS Noetic.
ros2-humble                                   0.1              A development and testing environment for ROS 2 Humble.

I'm using Multipass 1.11.0 on Linux.

Suspiciously, we started seeing the same error on a Github CI runner around the same time you reported the error. I don't see any status problems for cloud-images.ubuntu.com. Not sure what's going on here.

@townsend2010 - do you have any advice?

talregev commented 1 year ago

How you run multipass on GitHub action? I try that and it give me an error of socket something.

talregev commented 1 year ago

I will publish my version and images list soon.

townsend2010 commented 1 year ago

Hey @mr-cal!

It's not clear to me what is going on. I need some more Multipass logs to help diagnose this.

Hi @talregev!

Could you please provide logs so I can see if there are any more details to shed a light on what is happening? Thanks!

talregev commented 1 year ago

What logs do you need?

townsend2010 commented 1 year ago

Hi @talregev!

The instructions for the logs I need are linked in the "provide logs" part above, but specifically https://multipass.run/docs/accessing-logs#heading--linux for getting me the Multipass logs that may help me diagnose why this is not working.

Thanks!

talregev commented 1 year ago

Do you also reproduce it on your ci?

townsend2010 commented 1 year ago

No, we don't use Multipass to build Multipass :wink:

I can't reproduce locally on my machine either.

talregev commented 1 year ago

I see the same error you got on your mac multipass on your ci

townsend2010 commented 1 year ago

Snapcraft is seeing this issue in their CI and they use Multipass for that particular part of CI.

I'm on the Multipass Team (different than Snapcraft) and I'm trying to determine where the issue may be which is why I'm requesting the logs here.

talregev commented 1 year ago

On your ci, mac multipass is 1.11.1. I will check my version soon.

talregev commented 1 year ago
 multipass --version
multipass   1.11.0
 multipass find
Image                       Aliases           Version          Description
snapcraft:core18            18.04             20201111         Snapcraft builder for Core 18
snapcraft:core20            20.04             20210921         Snapcraft builder for Core 20
snapcraft:core22            22.04             20220426         Snapcraft builder for Core 22
snapcraft:devel                               20230418         Snapcraft builder for the devel series
core                        core16            20200818         Ubuntu Core 16
core18                                        20211124         Ubuntu Core 18
core20                                        20230119         Ubuntu Core 20
core22                                        20230119         Ubuntu Core 22
18.04                       bionic            20230329         Ubuntu 18.04 LTS
20.04                       focal             20230209         Ubuntu 20.04 LTS
22.04                       jammy,lts         20230416         Ubuntu 22.04 LTS
22.10                       kinetic           20230418         Ubuntu 22.10
appliance:adguard-home                        20200812         Ubuntu AdGuard Home Appliance
appliance:mosquitto                           20200812         Ubuntu Mosquitto Appliance
appliance:nextcloud                           20200812         Ubuntu Nextcloud Appliance
appliance:openhab                             20200812         Ubuntu openHAB Home Appliance
appliance:plexmediaserver                     20200812         Ubuntu Plex Media Server Appliance
anbox-cloud-appliance                         latest           Anbox Cloud Appliance
charm-dev                                     latest           A development and testing environment for charmers
docker                                        0.4              A Docker environment with Portainer and related tools
jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube                                      latest           minikube is local Kubernetes
ros-noetic                                    0.1              A development and testing environment for ROS Noetic.
ros2-humble                                   0.1              A development and testing environment for ROS 2 Humble.
talregev commented 1 year ago

Can you reproduce this issue directly from the command line, using multipass launch snapcraft:core22?

I will try with snapcraft:core22 and let you know.

talregev commented 1 year ago

here some logs: logs.txt

mr-cal commented 1 year ago

Our CI started passing again, I am no longer seeing failures.

talregev commented 1 year ago

Now it work on my side. I think you should report it to multipass. It come and goes.

talregev commented 1 year ago

I will close this issue because it solve for me. Feel free to open it on multipass.

Jayce-liang commented 1 year ago

i have same issue on ubuntu arm64. so how should i do?

mr-cal commented 1 year ago

Hi @Jayce-liang, this is likely because Multipass's images for snapcraft are not currently available on arm64. Can you open this in a new issue, so we can keep the discussion separate? Thanks!

Jayce-liang commented 1 year ago

Hi @Jayce-liang, this is likely because Multipass's images for snapcraft are not currently available on arm64. Can you open this in a new issue, so we can keep the discussion separate? Thanks!

ok,thanks