graphite-project/graphite-web — pull request #169 by sfoutrier (2013-03-11 17:31:13+00:00)
Title: Remote carbonlink fix

Accessing metric when on remote server throws exception.

Thu Feb 28 13:35:38 2013 :: Exception Caught
Traceback (most recent call last):
File "/opt/graphite/webapp/graphite/render/datalib.py", line 226, in fetchData
cachedResults = CarbonLink.query(dbFile.real_metric)
File "/opt/graphite/webapp/graphite/render/datalib.py", line 135, in query
results = self.send_request(request)
File "/opt/graphite/webapp/graphite/render/datalib.py", line 158, in send_request
conn = self.get_connection(host)
File "/opt/graphite/webapp/graphite/render/datalib.py", line 125, in get_connection
connection.connect( (server, port) )
File "", line 1, in connect
error: [Errno 111] Connection refused

or if no local carbon-cache:

Fri Feb 22 13:47:00 2013 :: Exception Caught
Traceback (most recent call last):
File "/opt/graphite/webapp/graphite/render/datalib.py", line 226, in fetchData
cachedResults = CarbonLink.query(dbFile.real_metric)
File "/opt/graphite/webapp/graphite/render/datalib.py", line 135, in query
results = self.send_request(request)
File "/opt/graphite/webapp/graphite/render/datalib.py", line 157, in send_request
host = self.select_host(metric)
File "/opt/graphite/webapp/graphite/render/datalib.py", line 109, in select_host
return self.hash_ring.get_node(metric)
File "/opt/graphite/webapp/graphite/render/hashing.py", line 83, in get_node
index %= len(self.ring)
ZeroDivisionError: integer division or modulo by zero

I stop trying to pull data from carbon-cache if the metric is found on a remote server since the local carbon-cache is it exists doesn't contains data about this metric.