mirror of https://github.com/docker/docs.git
Fix scale when containers exit immediately
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
e35bf47a7f
commit
755c49b500
|
@ -228,11 +228,9 @@ class Service(object):
|
||||||
sorted_running_containers = sorted(
|
sorted_running_containers = sorted(
|
||||||
running_containers,
|
running_containers,
|
||||||
key=attrgetter('number'))
|
key=attrgetter('number'))
|
||||||
parallel_stop(
|
containers_to_stop = sorted_running_containers[-num_to_stop:]
|
||||||
sorted_running_containers[-num_to_stop:],
|
parallel_stop(containers_to_stop, dict(timeout=timeout))
|
||||||
dict(timeout=timeout))
|
parallel_remove(containers_to_stop, {})
|
||||||
|
|
||||||
parallel_remove(self.containers(stopped=True), {})
|
|
||||||
|
|
||||||
def create_container(self,
|
def create_container(self,
|
||||||
one_off=False,
|
one_off=False,
|
||||||
|
|
|
@ -746,6 +746,11 @@ class ServiceTest(DockerClientTestCase):
|
||||||
for container in containers:
|
for container in containers:
|
||||||
self.assertEqual(list(container.inspect()['HostConfig']['PortBindings'].keys()), ['8000/tcp'])
|
self.assertEqual(list(container.inspect()['HostConfig']['PortBindings'].keys()), ['8000/tcp'])
|
||||||
|
|
||||||
|
def test_scale_with_immediate_exit(self):
|
||||||
|
service = self.create_service('web', image='busybox', command='true')
|
||||||
|
service.scale(2)
|
||||||
|
assert len(service.containers(stopped=True)) == 2
|
||||||
|
|
||||||
def test_network_mode_none(self):
|
def test_network_mode_none(self):
|
||||||
service = self.create_service('web', net=Net('none'))
|
service = self.create_service('web', net=Net('none'))
|
||||||
container = create_and_start_container(service)
|
container = create_and_start_container(service)
|
||||||
|
|
Loading…
Reference in New Issue