jclouds/jclouds — pull request #626 by aledsage (2012-05-11 09:29:22+00:00)
Title: Issue-858: fix timeout waiting for port connection, and abort when node!=running

Issue-858: long timeout when VM startup fails. There are two situations where it annoys the user: 1) something has gone wrong with the VM such that it's "running" but will never have a port available; 2) the user terminates the VM (which was previously "running") because they can tell it's borked. In both these situations, the long timeout annoys the user.

Two fixes:

1. Previously, we'd wait for the timeout period for each IP sequentially - so if user configured a 5 mins timeout and there was one public and one private IP, it would take 10 mins to timeout. This required switching from using RetryIfSocketNotYetOpen, and instead looping over each IP:port in a predicate in ComputeServiceUtilsTest.

2. Pass in the nodeRunning predicate, so we abort waiting for the port if the node is no longer running.

---
A few things I'm not sure about:
* Should we rely on nodeRunning like this? Perhaps if nodeRunning(AtomicReference) fails to lookup the node again then we shouldn't abort yet (e.g. it could be due to local network dropping off temporarily?). Can we tell that by the AtomicReference then containing null? Or some other way?
* RetryIfSocketNotYetOpen is no longer used in the main code-base, but is still used in labs (in virtualbox, at least).
* In ComputeServiceUtil.findReachableSocketOnNode, there's now a fair amount of code. This could be extracted to another class potentially, but I think it's ok for now...