beringresearch / macpine

Lightweight Linux VMs on MacOS
https://beringresearch.github.io/macpine/
Apache License 2.0
898 stars 22 forks source link

[Bug] Startup fails with LXD image, emulated x86_64 architecture, and large memory (>2GB) #143

Closed idroz closed 1 year ago

idroz commented 1 year ago

Describe the bug As above

To Reproduce Steps to reproduce the behavior:

  1. alpine launch --image alpine_3.16.0_lxd --name lxd --port 8443 --arch x86_64 --ssh 23 --cpu 12 -d 20G -m 6144
2023/05/04 13:23:24 awaiting ssh server...
2023/05/04 13:23:42 lxd stopped
2023/05/04 13:23:42 failed to start lxd: ssh: handshake failed: read tcp 127.0.0.1:49566->127.0.0.1:23: read: connection reset by peer
2023/05/04 13:23:42 error starting instance(s)

Expected behaviour Able to launch and ssh into VM

May be related to #57

idroz commented 1 year ago

Oddly enough, seems to be working now. I'm not sure what's happening. Will keep this open in case it's reproducible.

maxzinkus commented 1 year ago

When I ran this, it failed and deleted the ~/.macpine/lxd directory, but the qemu-system-x86_64 process is running and listening on ports 8443 and 4022. However, trying to SSH ssh -p 4022 root@localhost hangs indefinitely. Definitely a bad error case. We should almost certainly kill -9 <pid> before we os.RemoveAll(~/.macpine/<instance>) in case the qemu instance stayed alive despite the failure.

alpine launch --image alpine_3.16.0_lxd --name lxd --port 8443 --arch x86_64 --ssh 4022 --cpu 2 -d 4G -m 6144
maxzinkus commented 1 year ago

alpine launch --port 8443 --arch x86_64 --ssh 4022 --cpu 2 -d 4G -m 6144 works perfectly so it's something about the lxd image in combination with the parameters. Changing issue title to reflect

idroz commented 1 year ago

Yup - I narrowed it down to the image itself, which I've updated and can push.

Before doing that, I was thinking that since we have a very nice import/export utility, perhaps launch should utilise that instead of simply downloading qcow2 files. It would also mean creating (and potentially exposing to the user) a way to import a macpine machine image from a URL, although will need to consider security implications.

Personally, I already have a set of use cases for a set of publically-hosted macpine machine images pre-configured with basics such as LXD, docker, etc.

What are your thoughts on this?

maxzinkus commented 1 year ago

That sounds awesome. We'd effectively be recreating something like DockerHub but for macpine, where people could upload and share links to images with descriptions for various use cases (e.g. basic LXD configuration, base nginx+node.js webapp, local mysqld, etc).

The only concern is where the data is actually hosted- I assume we don't want to spin up hosting for arbitrary images. But it would be really nice to have a page where you could browse images and choose ones to download with macpine import --url <some url>.

maxzinkus commented 1 year ago

Perhaps if we could automate creating a GitHub gist on the command line, GitHub could provide the backing storage and a place for the description (gists have text accompanying them)?

maxzinkus commented 1 year ago

We could add a confirmation to alpine import --url, something like:

$ alpine import --url https://gist.github.com/maxzinkus/example-uuid
images imported from URLs are not checked for malicious code/configurations, continue? [y/N] y
downloading image from https://gist.github.com/maxzinkus/example-uuid ...
...
idroz commented 1 year ago

Nice -

I like this approach. Coupled with age encryption I think this could work nicely.

I'll pick this up and work on it over the w/e

maxzinkus commented 1 year ago

Either way, if we could have alpine publish --upload and/or alpine upload also post a published archive (using a gist backend or another -- pastebin?) in a way that we can index, that'd help create the DockerHub-like experience.

maxzinkus commented 1 year ago

Moved new feature tracking to #144

SteveMcGrath commented 1 year ago

Not to necro a closed issue, but I'm running into the same issue with the LXD image. Did that updated image every get published? any way to force it to pull the new image if thats the case?

idroz commented 1 year ago

I’ve got it sorted locally. Must have forgotten to push the updated image. Will be able to push it out tomorrow . Sorry about that!

idroz commented 1 year ago

@SteveMcGrath that's done. You should be able to launch the pre-baked lxd image with:

alpine launch --image alpine_3.16.0_lxd --name lxd --port 8443 --ssh 2222 --arch x86_64

and then set up LXD using instructions at https://beringresearch.github.io/macpine/lxd_macpine/

SteveMcGrath commented 1 year ago

Deleted the cache and it fired up just fine. Thanks!