Skip to content

Commit

Permalink
Upgrade docker-py to its latest version (docker==3.1.1) (#3243)
Browse files Browse the repository at this point in the history
* Upgrade docker-py to its latest version (1.10.6)

* Hardcode 1.19 as Docker version

* Upgrade to latest possible docker/requests version

* Lint

* Fix import mistake from previous merge

* Fix merge conflict on creating container host config

* Remove unused import

* create_host_config fixed by calling it from the Docker client

* Upgrade docker and requests to their latest versions
  • Loading branch information
humitos authored and agjohnson committed Mar 15, 2018
1 parent 50e7d4b commit d30cc12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
import socket
from datetime import datetime

from readthedocs.core.utils import slugify
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from docker import Client
from docker.utils import create_host_config
from docker import APIClient
from docker.errors import APIError as DockerAPIError, DockerException
from slumber.exceptions import HttpClientError

from readthedocs.builds.constants import BUILD_STATE_FINISHED
from readthedocs.builds.models import BuildCommandResultMixin
from readthedocs.core.utils import slugify
from readthedocs.projects.constants import LOG_TEMPLATE
from readthedocs.restapi.client import api as api_v2
from requests.exceptions import ConnectionError
Expand Down Expand Up @@ -723,10 +722,9 @@ def get_client(self):
"""Create Docker client connection."""
try:
if self.client is None:
self.client = Client(
self.client = APIClient(
base_url=self.docker_socket,
version=DOCKER_VERSION,
timeout=None
)
return self.client
except DockerException as e:
Expand Down Expand Up @@ -778,9 +776,12 @@ def get_container_host_config(self):
self.project.pip_cache_path: {
'bind': self.project.pip_cache_path,
'mode': 'rw',
}
},
})
return create_host_config(binds=binds)
return self.get_client().create_host_config(
binds=binds,
mem_limit=self.container_mem_limit,
)

@property
def container_id(self):
Expand Down Expand Up @@ -839,7 +840,6 @@ def create_container(self):
host_config=self.get_container_host_config(),
detach=True,
environment=self.environment,
mem_limit=self.container_mem_limit,
)
client.start(container=self.container_id)
except ConnectionError as e:
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/rtd_tests/mocks/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self):
'readthedocs.doc_builder.backends.sphinx.EpubBuilder.move'),
'glob': mock.patch('readthedocs.doc_builder.backends.sphinx.glob'),

'docker': mock.patch('readthedocs.doc_builder.environments.Client'),
'docker': mock.patch('readthedocs.doc_builder.environments.APIClient'),
'docker_client': mock.Mock(),
}
self.mocks = {}
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ stripe==1.20.2

django-formtools==2.1
django-dynamic-fixture==2.0.0
docker-py==1.3.1
docker==3.1.1
django-textclassifier==1.0
django-annoying==0.10.4
django-messages-extends==0.6.0
Expand Down

0 comments on commit d30cc12

Please sign in to comment.