Skip to content

Commit

Permalink
Filter ASG listing for healthy and in services instances
Browse files Browse the repository at this point in the history
  • Loading branch information
bplessis-swi committed Oct 4, 2023
1 parent 653b5da commit 8317e85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 0 additions & 2 deletions pkg/lookable/asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ func (asg AutoScalingGroup) doLookupIPs(as ASGAPI, ec EC2API, ctx context.Contex
// No healthy instances
if len(instances) == 0 {
return nil, nil
}


// Find running instances IP
params3 := &ec2.DescribeInstancesInput{
Expand Down
18 changes: 16 additions & 2 deletions pkg/lookable/asg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ func TestLookupASG(t *testing.T) {
/* Single instance result */
{
client: func(t *testing.T) (ASGAPI,EC2API) {
instanceId := "inst-2016584701"
instanceId1 := "inst-2016584701"
instanceId2 := "inst-2016584702"
instanceId2 := "inst-2016584703"

return &MockASGAPI{
DescribeAutoScalingGroupsMethod: func(ctx context.Context, params *autoscaling.DescribeAutoScalingGroupsInput, optFns...func(*autoscaling.Options)) (*autoscaling.DescribeAutoScalingGroupsOutput, error) {
Expand All @@ -38,7 +40,19 @@ func TestLookupASG(t *testing.T) {
{
Instances: []asgtypes.Instance{
{
InstanceId: &instanceId,
InstanceId: &instanceId1,
HealthStatus: "Healthy",
LifeCycleState: "InService",
},
{
InstanceId: &instanceId2,
HealthStatus: "Degraded",
LifeCycleState: "Pending",
},
{
InstanceId: &instanceId3,
HealthStatus: "Healthy",
LifeCycleState: "Terminating",
},
},
},
Expand Down

0 comments on commit 8317e85

Please sign in to comment.