> @@ -94,6 +97,12 @@ public boolean apply(FloatingIP arg0) { > // try to prevent multiple parallel launches from choosing the same > ip. > Collections.shuffle(unassignedIps); > ip = Iterables.getLast(unassignedIps); > + > + //if we are still unable to allocate IP, even after iterating > through all > + //available, then re-throw IRE as there is nothing left we can do > + if(ip == null){ > + throw new InsufficientResourcesException("Failed to allocate a > FloatingIP for node(" + node.getId() + ")",e); > + } > } > logger.debug(">> adding floatingIp(%s) to node(%s)", ip.getIp(), > node.getId());
Here is what I'm talking about. Is this the solution we want to go with? FloatingIP ip = null; try { logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId()); // throw InsufficientResourcesException on 400 from server or null if 404 from server ip = floatingIpApi.create(); if(ip == null){ ip = allocateIPFromFloatingIPApiList(floatingIpApi); if(ip == null){ throw new NullPointerException("Failed to allocate a FloatingIP for node(" + node.getId() + ")"); } } } catch (InsufficientResourcesException e) { logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId()); logger.trace(">> searching for existing, unassigned floating ip for node(%s)", node.getId()); ip = allocateIPFromFloatingIPApiList(floatingIpApi); // if we are still unable to allocate IP, even after iterating through all // available, then re-throw IRE as there is nothing left we can do if(ip == null){ throw new InsufficientResourcesException("Failed to allocate a FloatingIP for node(" + node.getId() + ")",e); } } --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/425/files#r14415348