ddelnano / packer-plugin-xenserver

A builder plugin for Packer.IO to support building XenServer images.
Mozilla Public License 2.0
71 stars 37 forks source link

Verify if the address of a new VM is reachable #130

Closed mmahnic closed 1 month ago

mmahnic commented 3 months ago

Currently packer often returns an address that is not reachable. With this change, Packer pings each received address and selects the one that responds.

Packer sometimes selects an invalid address of a newly created machine. It takes the default address '0/ip' (copy of '0/ipv4/0' in the example below). This address is often not reachable or may even be empty, but Packer does not verify that. In this example we get an address that looks like some XenServer internal address (169) instead of the public one (172):

    ==> xenserver-iso.windows10-xen: Step: Wait for VM's IP to become known to us.
        xenserver-iso.windows10-xen: Net '0/ipv6/0' IP 'fe80:0000:0000:0000:*'
        xenserver-iso.windows10-xen: Net '0/ipv4/0' IP '169.254.**.**'
        xenserver-iso.windows10-xen: Net '0/ipv6/0' IP 'fe80:0000:0000:0000:*'
        xenserver-iso.windows10-xen: Net '0/ipv4/1' IP '172.21.**.**'
        xenserver-iso.windows10-xen: Net '0/ip' IP '169.254.**.**'
        xenserver-iso.windows10-xen: Got IP '169.254.**.**' from XenServer tools
    ==> xenserver-iso.windows10-xen: Got IP address '169.254.**.**'

With this patch, Packer pings all the addresses for the new VM returned by XenServer and selects the first one that is accessible. It always starts with '0/ip'.

    ==> xenserver-iso.windows10-xen: Step: Wait for VM's IP to become known to us.
        xenserver-iso.windows10-xen: Got IP '' from XenServer tools. Not accessible.
        xenserver-iso.windows10-xen: Got IP '172.21.**.**' from XenServer tools
    ==> xenserver-iso.windows10-xen: Got IP address '172.21.**.**' 

EDIT: This change may be solving the same problem as #62, but in a different way. Maybe a combination of both approaches will be necessary.

mmahnic commented 1 month ago

Closing because the current ping implementation is not reliable.