Skip to content

Commit

Permalink
Merge pull request #15 from adamjkeller/INFRASYS-6322
Browse files Browse the repository at this point in the history
INFRASYS-6322 - Autoscaling down to original count when no new instan…
  • Loading branch information
adamjkeller committed Nov 20, 2015
2 parents 474b276 + db60964 commit 555b340
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions License2Deploy/rolling_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def get_instance_ids_by_requested_build_tag(self, id_list, build):

if not new_instances:
logging.error("There are no instances in the group with build number {0}. Please ensure AMI was promoted.\nInstance ID List: {1}".format(build, id_list))
group_name = self.get_autoscale_group_name()
self.set_autoscale_instance_desired_count(self.calculate_autoscale_desired_instance_count(group_name, 'decrease'), group_name)
exit(self.exit_error_code)

id_ip_dict = self.get_instance_ip_addrs(new_instances)
Expand Down
3 changes: 3 additions & 0 deletions tests/rolling_deploy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ def test_get_all_instance_ids(self):
self.assertEqual(len(instance_ids), len(rslt))

@mock_ec2
@mock_autoscaling
def test_get_instance_ids_by_requested_build_tag(self):
self.setUpEC2()
self.setUpAutoScaleGroup()
conn = boto.connect_ec2()
new_inst = []
res_ids = conn.get_all_instances()
Expand All @@ -197,6 +199,7 @@ def test_get_instance_ids_by_requested_build_tag(self):
if [y for y in name.tags if y == 'BUILD' and name.tags['BUILD'] == '0']:
new_inst.append(name.id)
self.assertEqual(len(self.rolling_deploy.get_instance_ids_by_requested_build_tag(new_inst, 0)), 2)
self.assertRaises(SystemExit, lambda: self.rolling_deploy.get_instance_ids_by_requested_build_tag(new_inst, 1))

@mock_ec2
def test_get_instance_ids_by_requested_build_tag_failure(self):
Expand Down

0 comments on commit 555b340

Please sign in to comment.