richleland/django-cumulus — Issue #31: 101, Network is unreachable
Author: rizumu
Created: 2011-11-17 08:15:18+00:00
State: open

When cloudfiles is unreachable, it raises an Exception that 500's the page, creating a single point of failure.

I believe cumulus is the right place to catch this error and surpress it, because ImageKit is image backend agnostic, and cloudfiles is doing its role by alerting that the file is unreachable.

For the page to render without 500ing, like a HTML file that has an link to a nonexisting image, seems appropiate. Better yet, If the error able to be caught in the application code for those who want to do something fancier, such as falling back to serving from a different location, or using a default image, could be the ideal.

However, maybe you suggest that is something better done in the application code? Interested to hear others thoughts on this.

Here are the relevant bits from the traceback.

```python
Environment:

Request Method: GET
Request URL: http://rizu.mu/

Traceback:
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/django/template/base.py" in _resolve_lookup
683. current = getattr(current, bit)
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/imagekit/models.py" in url
178. self.generate()
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/imagekit/models.py" in generate
191. if lazy and (getattr(self, '_file', None) or self.storage.exists(self.name)):
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cumulus/storage.py" in exists
143. self._get_cloud_obj(name)
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cumulus/storage.py" in _get_cloud_obj
93. return self.container.get_object(name)
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cloudfiles/utils.py" in decorator
45. return f(*args, **kwargs)
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cloudfiles/container.py" in get_object
317. return Object(self, object_name, force_exists=True)
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cloudfiles/storage_object.py" in __init__
91. if not self._initialize() and force_exists:
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cloudfiles/storage_object.py" in _initialize
525. 'HEAD', [self.container.name, self.name])
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cloudfiles/connection.py" in make_request
192. response = retry_request()
File "/home/deploy/.virtualenvs/rizumu/lib/python2.7/site-packages/cloudfiles/connection.py" in retry_request
185. self.connection.request(method, path, data, headers)
File "/usr/lib/python2.7/httplib.py" in request
955. self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py" in _send_request
989. self.endheaders(body)
File "/usr/lib/python2.7/httplib.py" in endheaders
951. self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py" in _send_output
811. self.send(msg)
File "/usr/lib/python2.7/httplib.py" in send
773. self.connect()
File "/usr/lib/python2.7/httplib.py" in connect
1154. self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py" in create_connection
571. raise err

Exception Type: error at /
Exception Value: (101, 'Network is unreachable')
```