Skip to content

run fails to discover guests via mDNS when created in host mode #259

Description

@tofugarden

Description

The run script uses avahi as a mDNS responder on guests, but installing it requires network access. When operating in host mode, package install fails. The user needs to manually track down the guest's address.

% ./run fedora-host --operation-mode=host --distro=fedora                                                                        
[   0.032] INFO Starting vmnet-helper for 'fedora-host' with interface id '21e0b888-67c1-499e-b9c8-578be0806c66'                                                
[   0.105] INFO Creating image '/Users/tofugarden/.vmnet-helper/vms/fedora-host/disk.img'                                                                       
[   0.112] INFO Creating cloud-init iso '/Users/tofugarden/.vmnet-helper/vms/fedora-host/cidata.iso'                                                            
[   0.120] INFO Starting 'vfkit' virtual machine 'fedora-host' with mac address 'fe:84:f3:1c:ab:b5'                                                             
[   0.120] INFO Creating ssh config '/Users/tofugarden/.vmnet-helper/vms/fedora-host/ssh.config'                                                                
[  60.155] WARNING Timeout waiting for vm to become reachable  

Proposed solution

On fedora, debian and ubuntu, systemd-resolved is included in cloud images, and starts by default. Using cloud-init, we can install a simple configuration file to /etc/systemd/resolved.conf:

#cloud-config
write_files:
- path: /etc/systemd/resolved.conf
  content: |
    [Resolve]
    MulticastDNS=yes

This also speeds up cloud-init a bit on resource-constrained systems like github runners, since we don't have to wait for package installation.

Potential issues

This doesn't work on alpine, since they don't ship a mDNS responder in cloud images.

As @nirs suggested in a comment on #258, we could internally bring up the VM in shared mode, install the package, then restart it in host mode.

We could also simply issue a warning that says something along the lines of "no mDNS in host mode on alpine," and let the user find the address through leases, the serial.log file, or arp tables. Kind of a shame, but this is still better than timing out like we do now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions