Fixes scaling values

parent 3c5cae99
......@@ -64,7 +64,7 @@ class ASG():
sleep(10)
logging.info("Scaling ASG back up")
self.scale(new_asg, self.scale_to, self.scale_to, self.scale_to)
self.scale(new_asg, self.scale_to['min'], self.scale_to['max'], self.scale_to['capacity'])
while len(self.get_auto_scaling_group_instances(new_asg)) < 1:
logging.info("Waiting for instances in ASG to start ...")
......@@ -275,15 +275,14 @@ class ASG():
def get_current_scale(self, asg):
"""
Gets the current scale of the given ASG, presuming that min, max, and desired
are all the same
Gets the current scales of the given ASG; {'desired', 'min', 'max'}
"""
if not self.scale_to:
asg_client = aws_client.create_client('autoscaling', self.region, self.role_arn)
asg = asg_client.describe_auto_scaling_groups(AutoScalingGroupNames=[asg])['AutoScalingGroups'][0]
return asg['DesiredCapacity']
return {"desired": asg['DesiredCapacity'], "min": asg['MinSize'], "max": asg['MaxSize']}
def get_auto_scaling_group_instances(self, auto_scaling_group_id, instance_ids=None):
asg_client = aws_client.create_client('autoscaling', self.region, self.role_arn)
......
......@@ -54,6 +54,7 @@ def reset(ctx, application_name):
@click.option("--lb", help="Loadbalancer to work out targetgroup from -- mutually exclusive with --asg and --target-group")
@click.option("--target-group", "target_group", help="Target Group to discover the ASG for updating. Mutually exclusive with --asg and --lb")
@click.option("--asg", "asg_name", help="ASG we're updating -- mutually exclusive with --lb and --target-group")
# FIXME: This will be broken now, and should instead be 3 separate options for min, max, and desired
@click.option("--scale-to", "scale_to", help="Optionally set the number for the ASG to scale back up to. Defaults to 1")
@click.option("--skip-status-check", "skip_status_check", is_flag=True, default=False, help="When passed, skips checking if we're already in the middle of a deploy")
def asg(ctx, ami, lb, asg_name, target_group, scale_to, skip_status_check):
......
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