rackerlabs/python-cloudlb — pull request #38 by calebgroom (2013-07-24 04:23:35+00:00)
Title: Adds AbsoluteLimit error

First: Don't use this library. Use [pyrax](https://github.com/rackspace/pyrax).

413 errors are always assumed to be rate limits. However, thats the same status code that's used for absolute limits. Absolute limits are not resolved by waiting so the response does not have a `retry-after` header.

Behavior before:

```
File "/some/path/local/lib/python2.7/site-packages/cloudlb/loadbalancers.py", line 178, in create
return self._create("/loadbalancers", body, "loadBalancer")
File "/some/path/local/lib/python2.7/site-packages/cloudlb/base.py", line 67, in _create
resp, body = self.api.client.post(url, body=body)
File "/some/path/local/lib/python2.7/site-packages/cloudlb/client.py", line 186, in post
return self._cloudlb_request(url, 'POST', **kwargs)
File "/some/path/local/lib/python2.7/site-packages/cloudlb/client.py", line 128, in _cloudlb_request
retry = datetime.datetime.strptime(response['retry-after'],
KeyError: 'retry-after'
```

Behavior after:
```
File "/some/path/python-cloudlb/cloudlb/loadbalancers.py", line 178, in create
return self._create("/loadbalancers", body, "loadBalancer")
File "/some/path/python-cloudlb/cloudlb/base.py", line 65, in _create
resp, body = self.api.client.post(url, body=body)
File "/some/path/python-cloudlb/cloudlb/client.py", line 198, in post
return self._cloudlb_request(url, 'POST', **kwargs)
File "/some/path/python-cloudlb/cloudlb/client.py", line 128, in _cloudlb_request
raise cloudlb.errors.AbsoluteLimit(data['message'])
cloudlb.errors.AbsoluteLimit: 413: Load balancer limit reached. Limit is set to '25'. Contact support if you would like to increase your limit.
```

It looks like the API is now protected by repose and a 404 response has a content-length of 0. The previous behavior tried to pull a message from the body which was raising a stacktrace too.