Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker's list_containers function #1043

Closed

Conversation

johnnyWalnut
Copy link
Contributor

@johnnyWalnut johnnyWalnut commented Apr 24, 2017

add an extra check otherwise list_containers breaks with AttributeError

Fix function list_containers for docker

Description

I tested locally docker's list_containers(), which was expected to return a list of containers.
But i ended up with this

<ipython-input-5-34990fe7ad41> in <module>()
----> 1 con.list_containers()

/home/johnny/Documents/mylibcloud/env/src/fork_libcloud/libcloud/libcloud/container/drivers/docker.py in list_containers(self, image, all)
    301             raise
    302 
--> 303         containers = [self._to_container(value) for value in result]
    304         return containers
    305 

/home/johnny/Documents/mylibcloud/env/src/fork_libcloud/libcloud/libcloud/container/drivers/docker.py in _to_container(self, data)
    622                 name = data.get('Names')[0].strip('/')
    623             except:
--> 624                 name = data.get('Id')
    625         state = data.get('State')
    626         if isinstance(state, dict):

AttributeError: 'list' object has no attribute 'get'

I investigated more and i fixed this previous commit
2f9c3a3

I extended the previous check with 'fromImage' in self.request.url, so to restrict that check which
refers to install_image and only. Because self.headers.get('transfer-encoding') == 'chunked' is valid in other cases too. This way everything seems to work fine!

done

Checklist (tick everything that applies)

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 467293a on johnnyWalnut:fix_docker_list_containers into ** on apache:trunk**.

@tonybaloney
Copy link
Contributor

👍

@tonybaloney
Copy link
Contributor

thanks for your contribution! merged.

@asfgit asfgit closed this in f7a90d8 Apr 29, 2017
asfgit pushed a commit that referenced this pull request Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants