Skip to content

Commit

Permalink
fix(ecs): Handle task def not cached yet (#3980)
Browse files Browse the repository at this point in the history
  • Loading branch information
clareliguori authored and Jon Schneider committed Aug 30, 2019
1 parent 95ea8e4 commit b93a55d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ private TaskHealth inferHealthNetworkInterfacedContainer(
Service loadBalancerService,
TaskDefinition taskDefinition) {

if (taskDefinition == null) {
return null;
}

List<LoadBalancer> loadBalancers = loadBalancerService.getLoadBalancers();

for (LoadBalancer loadBalancer : loadBalancers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,30 @@ class TaskHealthCachingAgentSpec extends Specification {
taskHealth.getTaskId() == CommonCachingAgent.TASK_ID_1
}

def 'should skip tasks with a non-cached task definition and aws-vpc mode'() {
given:
ObjectMapper mapper = new ObjectMapper()
Map<String, Object> containerMap = mapper.convertValue(new Container().withNetworkInterfaces(
new NetworkInterface().withPrivateIpv4Address("192.168.0.100")),
Map.class)
def taskAttributes = [
taskId : CommonCachingAgent.TASK_ID_1,
taskArn : CommonCachingAgent.TASK_ARN_1,
startedAt : new Date().getTime(),
group : 'service:' + CommonCachingAgent.SERVICE_NAME_1,
containers : Collections.singletonList(containerMap)
]
def taskKey = Keys.getTaskKey(CommonCachingAgent.ACCOUNT, CommonCachingAgent.REGION, CommonCachingAgent.TASK_ID_1)
def taskCacheData = new DefaultCacheData(taskKey, taskAttributes, Collections.emptyMap())
providerCache.getAll(TASKS.toString(), _) >> Collections.singletonList(taskCacheData)

when:
def taskHealthList = agent.getItems(ecs, providerCache)

then:
taskHealthList == []
}

def 'should generate fresh data'() {
given:
def taskIds = [CommonCachingAgent.TASK_ID_1, CommonCachingAgent.TASK_ID_2]
Expand Down

0 comments on commit b93a55d

Please sign in to comment.