'Populate the cache of ecs tags. Can be called with skip_known=True
If we just want to update new containers quickly (single task api call)
(because we detected that a new task started for example)'

def _populate_ecs_tags(self, skip_known=False):

    if (self.agent_url is None):
        self.log.warning('ecs-agent    not    found,    skipping    task    tagging')
        return
    try:
        tasks = requests.get((self.agent_url + ECS_AGENT_TASKS_PATH), timeout=1).json()
        for task in tasks.get('Tasks', []):
            for container in task.get('Containers', []):
                cid = container['DockerId']
                if (skip_known and (cid in self.ecs_tags)):
                    continue
                tags = [('task_name:%s' % task['Family']), ('task_version:%s' % task['Version'])]
                self.ecs_tags[container['DockerId']] = tags
    except requests.exceptions.HTTPError as ex:
        self.log.warning(('Unable    to    collect    ECS    task    names:    %s' % ex))
