Merge pull request #4919 from hashicorp/fix4798
builder/vmware: make vnc probe timeout configurable
This commit is contained in:
commit
730cc0889e
|
@ -198,6 +198,16 @@ func (d *ESX5Driver) VNCAddress(_ string, portMin, portMax uint) (string, uint,
|
|||
}
|
||||
}
|
||||
|
||||
vncTimeout := time.Duration(15)
|
||||
envTimeout := os.Getenv("PACKER_ESXI_VNC_PROBE_TIMEOUT")
|
||||
if envTimeout != "" {
|
||||
if parsedTimeout, err := time.ParseDuration(envTimeout); err != nil {
|
||||
log.Printf("Error parsing PACKER_ESXI_VNC_PROBE_TIMEOUT. Falling back to default (15s). %s", err)
|
||||
} else {
|
||||
vncTimeout = parsedTimeout
|
||||
}
|
||||
}
|
||||
|
||||
for port := portMin; port <= portMax; port++ {
|
||||
if _, ok := listenPorts[fmt.Sprintf("%d", port)]; ok {
|
||||
log.Printf("Port %d in use", port)
|
||||
|
@ -205,7 +215,7 @@ func (d *ESX5Driver) VNCAddress(_ string, portMin, portMax uint) (string, uint,
|
|||
}
|
||||
address := fmt.Sprintf("%s:%d", d.Host, port)
|
||||
log.Printf("Trying address: %s...", address)
|
||||
l, err := net.DialTimeout("tcp", address, 30*time.Second)
|
||||
l, err := net.DialTimeout("tcp", address, vncTimeout)
|
||||
|
||||
if err != nil {
|
||||
if e, ok := err.(*net.OpError); ok {
|
||||
|
|
|
@ -482,6 +482,21 @@ modify as well:
|
|||
format of the exported virtual machine. This defaults to "ovf".
|
||||
Before using this option, you need to install `ovftool`.
|
||||
|
||||
|
||||
### VNC port discovery
|
||||
|
||||
Packer needs to decide on a port to use for VNC when building remotely. To find
|
||||
an open port, we try to connect to ports in the range of `vnc_port_min` to
|
||||
`vnc_port_max`. If we notice something is listening on a port in the range, we
|
||||
try to connect to the next one, and so on until we find a port that has nothing
|
||||
listening on it. If you have many clients building on the ESXi host, there
|
||||
might be competition for the VNC ports. You can adjust how long packer waits
|
||||
for a connection timeout by setting `PACKER_ESXI_VNC_PROBE_TIMEOUT`. This
|
||||
defaults to 15 seconds. Set this shorter if vnc connections are refused, and
|
||||
set it longer if Packer can't find an open port. This is intended as an
|
||||
advanced configuration option. Please make sure your firewall settings are
|
||||
correct before adjusting.
|
||||
|
||||
### Using a Floppy for Linux kickstart file or preseed
|
||||
|
||||
Depending on your network configuration, it may be difficult to use packer's
|
||||
|
|
Loading…
Reference in New Issue