Skip to content

Commit

Permalink
[docker_daemon] refactoring refresh_ecs_tags for readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
truthbk committed Sep 6, 2016
1 parent 45cf3a8 commit 9b60949
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions checks.d/docker_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,12 @@ def refresh_ecs_tags(self):
ip = ecs_config.get('NetworkSettings', {}).get('IPAddress')
ports = ecs_config.get('NetworkSettings', {}).get('Ports')
port = ports.keys()[0].split('/')[0] if ports else None
if not ip and DockerUtil.is_dockerized():
if self.docker_gateway:
ip = self.docker_gateway
port = ECS_INTROSPECT_DEFAULT_PORT
elif not ip:
ip = "localhost"
if not ip:
port = ECS_INTROSPECT_DEFAULT_PORT
if DockerUtil.is_dockerized() and self.docker_gateway():
ip = self.docker_gateway
else:
ip = "localhost"

ecs_tags = {}
try:
Expand All @@ -452,7 +451,7 @@ def refresh_ecs_tags(self):
for container in task.get('Containers', []):
tags = ['task_name:%s' % task['Family'], 'task_version:%s' % task['Version']]
ecs_tags[container['DockerId']] = tags
except requests.exceptions.HTTPError as e:
except (requests.exceptions.HTTPError, requests.exceptions.HTTPError) as e:
self.log.warning("Unable to collect ECS task names: %s" % e)

self.ecs_tags = ecs_tags
Expand Down

0 comments on commit 9b60949

Please sign in to comment.