> @@ -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());
Jclouds implements APIs in a declarative way, and automatically generates the
request based on the method declaration. For the `create` method, there is
[this
fallback](https://github.com/jclouds/jclouds/blob/master/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java#L105)
defined, which will make the method return `null` when the server returns a
404 response. For responses codes that are not explicitly mapped in the API
method, the [error
handler](https://github.com/jclouds/jclouds/blob/master/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java#L73)
is invoked, so:
* The API will return `null` when the server returns a 404.
* It will throw the IRE when the server returns a 400 with a `quota exceeded`
message.
This is related to the test I also mentioned mentioned. It currently covers
[the 400
response](https://github.com/jclouds/jclouds/blob/master/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java#L97-L130)
path, but not the 404 one (that's the one I asked to add by copying the
existing 400 test).
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/425/files#r14413173