Pārlūkot izejas kodu

Merge pull request #4528 from shin-/4430-divergent-scale

Check for divergent containers when scaling up
Joffrey F 8 gadi atpakaļ
vecāks
revīzija
a953651597
1 mainītis faili ar 13 papildinājumiem un 2 dzēšanām
  1. 13 2
      compose/service.py

+ 13 - 2
compose/service.py

@@ -226,9 +226,20 @@ class Service(object):
 
             if num_running != len(all_containers):
                 # 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(
-                    (c for c in all_containers if not c.is_running),
-                    key=attrgetter('number'))
+                    set(stopped_containers) - set(divergent_containers),
+                    key=attrgetter('number')
+                )
+                for c in divergent_containers:
+                        c.remove()
 
                 num_stopped = len(stopped_containers)