Skip to content

Commit

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

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

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 +213,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 skippableStates = [
InstanceStateName.ShuttingDown.toString(),
InstanceStateName.Terminated.toString()
]

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

0 comments on commit 2ab1933

Please sign in to comment.