Commit a79924fb authored by Bozhidar Zhelev's avatar Bozhidar Zhelev

[HCSD-7541] makes sure the new ASG is provisioned with number of instances...

[HCSD-7541] makes sure the new ASG is provisioned with number of instances equal to the currently running ones in the old ASG
parent 16d223d0
......@@ -89,12 +89,14 @@ class ASG():
logging.info("Waiting for instances in ASG '{}' to terminate".format(inactive_asg))
sleep(10)
# Scales the new ASG back up but makes sure the instances in it are equal
# to the ones currently in the old ASG to not have performance drop (i.e. 5 -> 2)
logging.info("Scaling ASG '{}' back up to ({}, {}, {})".format(inactive_asg, scale_to['min'], scale_to['max'], scale_to['desired']))
self.scale(
auto_scaling_group_id = inactive_asg,
min_size = scale_to['min'],
min_size = scale_to['desired'],
max_size = scale_to['max'],
desired = scale_to['desired']
desired = scale_to['desired']
)
while len(self.get_auto_scaling_group_instances(inactive_asg)) < 1:
......
......@@ -137,4 +137,20 @@ class TargetGroup():
else:
logging.info("Done!")
# Make sure the newly attached ASG has minimum size of 2
logging.info(f"Sets minimum size = 2 for the {inactive_asg_name} ASG...")
try:
for asg in inactive_asg:
asg_client.update_auto_scaling_group(
AutoScalingGroupName=asg['AutoScalingGroupName'],
MinSize=2
)
except Exception as e:
logging.error(f"Couldn't change the minimum size of the {inactive_asg_name} ASG!")
logging.error(e)
# FIXME: Raise an exception.AkinakaCriticalException above instead of catching this
exit(1)
else:
logging.info("Done!")
return
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment