Commit aba343e2 authored by Daniele Venzano's avatar Daniele Venzano

Try to cope with KairosDB connection failures

parent 79c271f8
......@@ -81,6 +81,8 @@ class StatsManager(threading.Thread):
node.service_stats[service_id]['memory_in_use'] = usage['mem_usage']
except KeyError: # happens while a service is being terminated
continue
except TypeError: # happens while KairosDB cannot be reached
continue
node_cores += usage['cpu_usage']
node_memory += usage['mem_usage']
......
......@@ -84,10 +84,15 @@ class KairosDBInMetrics:
]
self._add_metric(query, "docker_container_mem", tags_memory, aggregators_memory, limit=0)
req = requests.post(self.metrics_url, json=query)
try:
req = requests.post(self.metrics_url, json=query)
except requests.exceptions.ConnectionError:
return None
return self._extract_data(req)
def _extract_data(self, response):
if response is None:
return None
if response.status_code != 200:
error_msg = ''
for error in response.json()['errors']:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment