mirror of
https://github.com/docker/compose.git
synced 2025-07-03 03:44:25 +02:00
Check for divergent containers when scaling up
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
c2553ac777
commit
3621787a74
@ -226,9 +226,20 @@ class Service(object):
|
|||||||
|
|
||||||
if num_running != len(all_containers):
|
if num_running != len(all_containers):
|
||||||
# we have some stopped containers, let's start them up again
|
# we have some stopped containers, let's start them up again
|
||||||
|
stopped_containers = [
|
||||||
|
c for c in all_containers if not c.is_running
|
||||||
|
]
|
||||||
|
|
||||||
|
# Remove containers that have diverged
|
||||||
|
divergent_containers = [
|
||||||
|
c for c in stopped_containers if self._containers_have_diverged([c])
|
||||||
|
]
|
||||||
stopped_containers = sorted(
|
stopped_containers = sorted(
|
||||||
(c for c in all_containers if not c.is_running),
|
set(stopped_containers) - set(divergent_containers),
|
||||||
key=attrgetter('number'))
|
key=attrgetter('number')
|
||||||
|
)
|
||||||
|
for c in divergent_containers:
|
||||||
|
c.remove()
|
||||||
|
|
||||||
num_stopped = len(stopped_containers)
|
num_stopped = len(stopped_containers)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user