Skip to content

Commit

Permalink
Merge pull request docker#6501 from chris-crone/build-fixes
Browse files Browse the repository at this point in the history
Various build fixes
  • Loading branch information
chris-crone authored Feb 5, 2019
2 parents 9de1f56 + c8a621b commit 3cddd1b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 46 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ENV LANG en_US.UTF-8
RUN useradd -d /home/user -m -s /bin/bash user
WORKDIR /code/

# FIXME(chris-crone): virtualenv 16.3.0 breaks build, force 16.2.0 until fixed
RUN pip install virtualenv==16.2.0
RUN pip install tox==2.1.1

ADD requirements.txt /code/
Expand All @@ -25,6 +27,7 @@ ADD .pre-commit-config.yaml /code/
ADD setup.py /code/
ADD tox.ini /code/
ADD compose /code/compose/
ADD README.md /code/
RUN tox --notest

ADD . /code/
Expand Down
78 changes: 39 additions & 39 deletions compose/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def scale(self, desired_num, timeout=None):
c for c in stopped_containers if self._containers_have_diverged([c])
]
for c in divergent_containers:
c.remove()
c.remove()

all_containers = list(set(all_containers) - set(divergent_containers))

Expand Down Expand Up @@ -467,50 +467,50 @@ def create_and_start(service, n):

def _execute_convergence_recreate(self, containers, scale, timeout, detached, start,
renew_anonymous_volumes):
if scale is not None and len(containers) > scale:
self._downscale(containers[scale:], timeout)
containers = containers[:scale]

def recreate(container):
return self.recreate_container(
container, timeout=timeout, attach_logs=not detached,
start_new_container=start, renew_anonymous_volumes=renew_anonymous_volumes
)
containers, errors = parallel_execute(
containers,
recreate,
lambda c: c.name,
"Recreating",
if scale is not None and len(containers) > scale:
self._downscale(containers[scale:], timeout)
containers = containers[:scale]

def recreate(container):
return self.recreate_container(
container, timeout=timeout, attach_logs=not detached,
start_new_container=start, renew_anonymous_volumes=renew_anonymous_volumes
)
for error in errors.values():
raise OperationFailedError(error)
containers, errors = parallel_execute(
containers,
recreate,
lambda c: c.name,
"Recreating",
)
for error in errors.values():
raise OperationFailedError(error)

if scale is not None and len(containers) < scale:
containers.extend(self._execute_convergence_create(
scale - len(containers), detached, start
))
return containers
if scale is not None and len(containers) < scale:
containers.extend(self._execute_convergence_create(
scale - len(containers), detached, start
))
return containers

def _execute_convergence_start(self, containers, scale, timeout, detached, start):
if scale is not None and len(containers) > scale:
self._downscale(containers[scale:], timeout)
containers = containers[:scale]
if start:
_, errors = parallel_execute(
containers,
lambda c: self.start_container_if_stopped(c, attach_logs=not detached, quiet=True),
lambda c: c.name,
"Starting",
)
if scale is not None and len(containers) > scale:
self._downscale(containers[scale:], timeout)
containers = containers[:scale]
if start:
_, errors = parallel_execute(
containers,
lambda c: self.start_container_if_stopped(c, attach_logs=not detached, quiet=True),
lambda c: c.name,
"Starting",
)

for error in errors.values():
raise OperationFailedError(error)
for error in errors.values():
raise OperationFailedError(error)

if scale is not None and len(containers) < scale:
containers.extend(self._execute_convergence_create(
scale - len(containers), detached, start
))
return containers
if scale is not None and len(containers) < scale:
containers.extend(self._execute_convergence_create(
scale - len(containers), detached, start
))
return containers

def _downscale(self, containers, timeout=None):
def stop_and_remove(container):
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coverage==4.4.2
ddt==1.2.0
flake8==3.5.0
mock>=1.0.1
mock==2.0.0
pytest==3.6.3
pytest-cov==2.5.1
2 changes: 1 addition & 1 deletion script/build/linux
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -ex
./script/clean

TAG="docker-compose"
docker build -t "$TAG" . | tail -n 200
docker build -t "$TAG" .
docker run \
--rm --entrypoint="script/build/linux-entrypoint" \
-v $(pwd)/dist:/code/dist \
Expand Down
8 changes: 4 additions & 4 deletions script/setup/osx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ if ! [ ${DEPLOYMENT_TARGET} == "$(macos_version)" ]; then
SDK_SHA1=dd228a335194e3392f1904ce49aff1b1da26ca62
fi

OPENSSL_VERSION=1.1.0h
OPENSSL_VERSION=1.1.0j
OPENSSL_URL=https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
OPENSSL_SHA1=0fc39f6aa91b6e7f4d05018f7c5e991e1d2491fd
OPENSSL_SHA1=dcad1efbacd9a4ed67d4514470af12bbe2a1d60a

PYTHON_VERSION=3.6.6
PYTHON_VERSION=3.6.8
PYTHON_URL=https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
PYTHON_SHA1=ae1fc9ddd29ad8c1d5f7b0d799ff0787efeb9652
PYTHON_SHA1=09fcc4edaef0915b4dedbfb462f1cd15f82d3a6f

#
# Install prerequisites.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cli/log_printer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_item_is_stop_with_cascade_stop(self):
queue.put(item)

generator = consume_queue(queue, True)
assert next(generator) is 'foobar-1'
assert next(generator) == 'foobar-1'

def test_item_is_none_when_timeout_is_hit(self):
queue = Queue()
Expand Down

0 comments on commit 3cddd1b

Please sign in to comment.