Code Monkey home page Code Monkey logo

Comments (7)

edigaryev avatar edigaryev commented on September 24, 2024

This is likely caused by this branch of code:

func typeBootCommandOverVNC(
ctx context.Context,
state multistep.StateBag,
config *Config,
ui packersdk.Ui,
tartRunStdout *bytes.Buffer,
) bool {
if config.HTTPDir != "" || len(config.HTTPContent) != 0 {
ui.Say("Detecting host IP...")
hostIP, err := detectHostIP(ctx, config)

If you use http_directory or http_content, we need to figure out the IP-address on which the VM will be able to reach the HTTP server running on host, and this requires a VM to obtain an IP address first, which takes time.

You can set http_bind_address manually to a value other than 0.0.0.0 to override this behavior, see also #63.

from packer-plugin-tart.

HariSekhon avatar HariSekhon commented on September 24, 2024

That would seem to explain the behaviour I'm seeing, but I've used http_directory setting with the packer builder plugin for VirtualBox and it didn't have this delay in sending keystrokes, which implies it didn't have to wait such a long time to determine the host VM as I was passing it this line:

ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/

so I think either I'm missing something or there is something more that needs to be done here.

Is it possible this is just some logic or optimization problem in the tart packer plugin itself since the VirtualBox packer plugin seems to have solved this?

Also, isn't the host IP usually the same IP each time, usually the first or second IP on the VM network. For example, I had created an alternative config where I was running my own web server locally and passing this to the tart VM:

'ds=nocloud-net;s=http://192.168.64.1:8000/'

which I'd reverse engineered from tty2 console on a tart VM itself and this worked consistently for me...

I just tried setting in the pkr.hcl:

http_bind_address = "192.168.64.1"

and the whole VM just hangs for 18 minutes so far:

$ packer build --force ubuntu-arm64.tart.http.pkr.hcl
ubuntu-22.04.tart-cli.ubuntu: output will be in this color.

<no_output>

from packer-plugin-tart.

HariSekhon avatar HariSekhon commented on September 24, 2024

After leaving it for over an hour it was still stuck.

Do I commented out the http_bind_address line and tried again:

packer build --force ubuntu-arm64.tart.http.pkr.hcl
ubuntu-22.04.tart-cli.ubuntu: output will be in this color.

==> ubuntu-22.04.tart-cli.ubuntu: Starting HTTP server on port 8798
==> ubuntu-22.04.tart-cli.ubuntu: Creating virtual machine...
==> ubuntu-22.04.tart-cli.ubuntu: Starting the virtual machine for installation...
==> ubuntu-22.04.tart-cli.ubuntu: Detecting host IP...

<stuck here for over 30 seconds - missed the boot loader's 30 second timeout>
<eventually continued but boot is hosed by that point>

==> ubuntu-22.04.tart-cli.ubuntu: Host IP is assumed to be 192.168.64.1
==> ubuntu-22.04.tart-cli.ubuntu: Waiting for the VNC server credentials from Tart...
==> ubuntu-22.04.tart-cli.ubuntu: Retrieved VNC credentials, connecting...
==> ubuntu-22.04.tart-cli.ubuntu: Connected to the VNC!
==> ubuntu-22.04.tart-cli.ubuntu: Typing the commands over VNC...
==> ubuntu-22.04.tart-cli.ubuntu: Waiting for the install process to shutdown the VM...

It looks like it failed to detect the host IP after a long period and missing the boot loader countdown

==> ubuntu-22.04.tart-cli.ubuntu: Host IP is assumed to be 192.168.64.1

perhaps this is why it's hanging and not sending the boot_command?

from packer-plugin-tart.

edigaryev avatar edigaryev commented on September 24, 2024

and the whole VM just hangs for 18 minutes so far:

This is probably because the interface with 192.168.64.1 address doesn't exist yet at the time of HTTP server creation and Packer's plugin SDK does not discern between bind: address already in use and bind: address family not supported by protocol family errors when starting the HTTP server, so it automatically re-tries the same operation over and over, but with another port and without logging any errors because it thinks that it's due to the occupied port.

I think you can fix this by binding to the IP-address that your macOS machine got from your LAN/WLAN, for example:

http_bind_address = "192.168.0.50"

Note that this will make your HTTP server available from the LAN too.

from packer-plugin-tart.

edigaryev avatar edigaryev commented on September 24, 2024

Regarding the root cause, do I understand correctly that even if you increase the GRUB_TIMEOUT in your Ubuntu autoinstall configuration, the VM will only get it's IP address via DHCP after booting?

from packer-plugin-tart.

HariSekhon avatar HariSekhon commented on September 24, 2024

So I tested setting the http_bind_address to the same IP my laptop has on the LAN and yes that does actually work around issue of not sending keystrokes in time for the bootloader and also the permanent hang from combining http_directory and http_bind_address.

The only downside is that being a DHCP address, this is not a permanent solution to packer configs on github which will need to run across machines of unknown IP addresses, run by people on the internet or shared with colleagues etc.

I mean I could easily script a search and replace of the local machine's IP address but it'd be such an ugly hack... aside from exposing the autoinstaller containing hashed passwords on the LAN...

from packer-plugin-tart.

HariSekhon avatar HariSekhon commented on September 24, 2024

How would I set GRUB_TIMEOUT in a packer build?

Ubuntu's AutoInstall isn't triggered because the keystrokes aren't sent and besides grub bootloader happens before autoinstaller...

Apologies if I'm missing something simple there.

from packer-plugin-tart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.