Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit a054e4c

Browse files
committed
Fix: instance were being terminated despite not having enough in the autoscaling group
1 parent c3d4853 commit a054e4c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lambda/src/instance_terminator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function terminateInstanceIn(autoscalingGroup, resolve, reject) {
6767
result: 'too few instances in group'
6868
};
6969
resolve(response);
70+
return;
7071
}
7172
const instances = autoscalingGroup['Instances'];
7273
const healthyInstances = instances.filter(instance => instance['LifecycleState'] == 'InService' && instance['HealthStatus'] == 'Healthy');
@@ -78,6 +79,7 @@ function terminateInstanceIn(autoscalingGroup, resolve, reject) {
7879
result: 'unhealthy instances in group'
7980
};
8081
resolve(response);
82+
return;
8183
} else {
8284
lookupOldestInstance(instances)
8385
.then(function (oldestInstance) {
@@ -88,6 +90,7 @@ function terminateInstanceIn(autoscalingGroup, resolve, reject) {
8890
instanceId: oldestInstance['InstanceId']
8991
};
9092
resolve(response);
93+
return;
9194
}).catch(function (error) {
9295
console.log(error);
9396
});

0 commit comments

Comments
 (0)