From 3c2c5ce2150c0f4cf886c6a2ff412cd7af36f375 Mon Sep 17 00:00:00 2001 From: Venkata Gunapati Date: Tue, 15 Oct 2019 23:05:50 -0700 Subject: [PATCH] Using autoscaling instead of ec2 for Termination (#53) --- cloud_provider/aws/aws_minion_manager.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cloud_provider/aws/aws_minion_manager.py b/cloud_provider/aws/aws_minion_manager.py index 5f5d7b7..973afb4 100644 --- a/cloud_provider/aws/aws_minion_manager.py +++ b/cloud_provider/aws/aws_minion_manager.py @@ -452,11 +452,13 @@ def run_or_die(self, instance, asg_meta, asg_semaphore): # Cordon and drain the node first self.cordon_node(instance) - - self._ec2_client.terminate_instances(InstanceIds=[instance.InstanceId]) + + # Terminate EC2 uisng autoscaling client + self._ac_client.terminate_instance_in_auto_scaling_group(InstanceId=instance.InstanceId, + ShouldDecrementDesiredCapacity=False) logger.info("Terminated instance %s", instance.InstanceId) asg_meta.remove_instance(instance.InstanceId) - logger.info("Removed instance %s from ASG %s", instance.InstanceId,asg_meta.get_name()) + logger.info("Removed instance %s from ASG %s", instance.InstanceId, asg_meta.get_name()) logger.info("Sleeping 180s before checking ASG") time.sleep(180) self.wait_for_all_running(asg_meta)