Skip to content

Commit

Permalink
fix(provider/amazon): Only include non-terminating instances (#2075)
Browse files Browse the repository at this point in the history
When building a set of partial instances, only include those
that are not pending or in-service.
  • Loading branch information
ajordens authored and jeyrschabu committed Nov 3, 2017
1 parent 59ed648 commit 27a9547
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.netflix.spinnaker.clouddriver.aws.provider.view

import com.amazonaws.services.autoscaling.model.LifecycleState
import com.amazonaws.services.ec2.model.InstanceStateName
import com.netflix.frigga.ami.AppVersion
import com.netflix.spinnaker.cats.cache.Cache
import com.netflix.spinnaker.cats.cache.CacheData
Expand Down Expand Up @@ -212,7 +214,14 @@ class AmazonClusterProvider implements ClusterProvider<AmazonCluster> {

if (!serverGroup.instances && serverGroupEntry.attributes.instances) {
// has no direct instance relationships but we can partially populate instances based on attributes.instances
serverGroup.instances = serverGroupEntry.attributes.instances.collect {
def validStates = [
LifecycleState.Pending.name(),
LifecycleState.InService.name()
]

serverGroup.instances = (serverGroupEntry.attributes.instances as List<Map>).findAll {
validStates.contains(it.lifecycleState)
}.collect {
new AmazonInstance(((Map) it) + [name: it.instanceId])
}
}
Expand Down

0 comments on commit 27a9547

Please sign in to comment.