]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
autoscaling: don't kill all instances when scaling down
authorAngus Salkeld <asalkeld@redhat.com>
Mon, 23 Jul 2012 10:12:05 +0000 (20:12 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Mon, 23 Jul 2012 10:12:05 +0000 (20:12 +1000)
only delete the difference between the old capacity and the new capacity

doh!

Change-Id: Idbb16b2fa93abcad2793d5b4365c18a01e588b99
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/engine/autoscaling.py

index 7389d9b559d59e57156f2ec7438dcf6727f3b351..86a51857de6e5ad01781740a535c6f91fef0a093 100644 (file)
@@ -101,7 +101,10 @@ class AutoScalingGroup(Resource):
             return
 
         if new_capacity == capacity:
+            logger.debug('no change in capacity %d' % capacity)
             return
+        logger.debug('adjusting capacity from %d to %d' % (capacity,
+                                                           new_capacity))
 
         conf = self.properties['LaunchConfigurationName']
         if new_capacity > capacity:
@@ -116,7 +119,7 @@ class AutoScalingGroup(Resource):
                 inst.create()
         else:
             # shrink (kill largest numbered first)
-            del_list = inst_list[:]
+            del_list = inst_list[new_capacity:]
             for victim in reversed(del_list):
                 inst = instance.Instance(victim,
                                          self.stack.t['Resources'][conf],