From bb09323446c23e61669e7b8d6ecb2be811c47062 Mon Sep 17 00:00:00 2001 From: Tomas Lin Date: Thu, 16 Feb 2017 11:55:28 -0800 Subject: [PATCH] (titus) move lookup of security group details to cluster caching time and remove instance caching agent since the functionality there is redundant. --- .../caching/TitusCachingProviderConfig.groovy | 16 +- .../agents/TitusClusterCachingAgent.groovy | 83 +++++++- .../agents/TitusInstanceCachingAgent.groovy | 183 ------------------ .../providers/TitusClusterProvider.groovy | 15 -- .../providers/TitusInstanceProvider.groovy | 6 - .../titus/caching/utils/AwsLookupUtil.groovy | 2 +- .../clouddriver/titus/client/model/Job.java | 7 + .../titus/model/TitusInstance.groovy | 2 +- .../titus/model/TitusServerGroup.groovy | 1 + 9 files changed, 95 insertions(+), 220 deletions(-) delete mode 100644 clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusInstanceCachingAgent.groovy diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/TitusCachingProviderConfig.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/TitusCachingProviderConfig.groovy index 2af453fe3c6..b28c2440234 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/TitusCachingProviderConfig.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/TitusCachingProviderConfig.groovy @@ -15,6 +15,7 @@ */ package com.netflix.spinnaker.clouddriver.titus.caching + import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature @@ -23,13 +24,15 @@ import com.netflix.spinnaker.cats.agent.CachingAgent import com.netflix.spinnaker.clouddriver.security.AccountCredentialsRepository import com.netflix.spinnaker.clouddriver.titus.TitusClientProvider import com.netflix.spinnaker.clouddriver.titus.TitusCloudProvider +import com.netflix.spinnaker.clouddriver.titus.caching.utils.AwsLookupUtil import com.netflix.spinnaker.clouddriver.titus.credentials.NetflixTitusCredentials import com.netflix.spinnaker.clouddriver.titus.caching.agents.TitusClusterCachingAgent -import com.netflix.spinnaker.clouddriver.titus.caching.agents.TitusInstanceCachingAgent import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.DependsOn +import javax.inject.Provider + @Configuration class TitusCachingProviderConfig { @@ -39,13 +42,16 @@ class TitusCachingProviderConfig { Registry registry, AccountCredentialsRepository accountCredentialsRepository, TitusClientProvider titusClientProvider, - ObjectMapper objectMapper) { + ObjectMapper objectMapper, + Provider awsLookupUtilProvider + ) { List agents = [] - def allAccounts = accountCredentialsRepository.all.findAll { it instanceof NetflixTitusCredentials } as Collection + def allAccounts = accountCredentialsRepository.all.findAll { + it instanceof NetflixTitusCredentials + } as Collection allAccounts.each { NetflixTitusCredentials account -> account.regions.each { region -> - agents << new TitusClusterCachingAgent(titusCloudProvider, titusClientProvider, account, region.name, objectMapper, registry) - agents << new TitusInstanceCachingAgent(titusClientProvider, account, region.name, objectMapper) + agents << new TitusClusterCachingAgent(titusCloudProvider, titusClientProvider, account, region.name, objectMapper, registry, awsLookupUtilProvider) } } new TitusCachingProvider(agents) diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusClusterCachingAgent.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusClusterCachingAgent.groovy index 014b9850b62..9e698d34d41 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusClusterCachingAgent.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusClusterCachingAgent.groovy @@ -33,18 +33,26 @@ import com.netflix.spinnaker.cats.cache.RelationshipCacheFilter import com.netflix.spinnaker.cats.provider.ProviderCache import com.netflix.spinnaker.clouddriver.cache.OnDemandAgent import com.netflix.spinnaker.clouddriver.cache.OnDemandMetricsSupport +import com.netflix.spinnaker.clouddriver.model.HealthState import com.netflix.spinnaker.clouddriver.titus.TitusClientProvider import com.netflix.spinnaker.clouddriver.titus.TitusCloudProvider +import com.netflix.spinnaker.clouddriver.titus.caching.utils.AwsLookupUtil +import com.netflix.spinnaker.clouddriver.titus.client.model.TaskState import com.netflix.spinnaker.clouddriver.titus.credentials.NetflixTitusCredentials import com.netflix.spinnaker.clouddriver.titus.caching.Keys import com.netflix.spinnaker.clouddriver.titus.caching.TitusCachingProvider import com.netflix.spinnaker.clouddriver.titus.client.TitusClient import com.netflix.spinnaker.clouddriver.titus.client.model.Job +import com.netflix.spinnaker.clouddriver.titus.model.TitusSecurityGroup import org.slf4j.Logger import org.slf4j.LoggerFactory +import javax.inject.Provider + +import static com.netflix.spinnaker.clouddriver.core.provider.agent.Namespace.HEALTH import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.APPLICATIONS import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.CLUSTERS +import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.IMAGES import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.ON_DEMAND import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.INSTANCES import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.SERVER_GROUPS @@ -59,7 +67,7 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { AUTHORITATIVE.forType(SERVER_GROUPS.ns), AUTHORITATIVE.forType(APPLICATIONS.ns), INFORMATIVE.forType(CLUSTERS.ns), - INFORMATIVE.forType(INSTANCES.ns) + AUTHORITATIVE.forType(INSTANCES.ns) ] as Set) private final TitusCloudProvider titusCloudProvider @@ -69,13 +77,16 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { private final ObjectMapper objectMapper private final Registry registry private final OnDemandMetricsSupport metricsSupport + private final Provider awsLookupUtil TitusClusterCachingAgent(TitusCloudProvider titusCloudProvider, TitusClientProvider titusClientProvider, NetflixTitusCredentials account, String region, ObjectMapper objectMapper, - Registry registry) { + Registry registry, + Provider awsLookupUtil + ) { this.titusCloudProvider = titusCloudProvider this.account = account this.region = region @@ -83,6 +94,7 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { this.titusClient = titusClientProvider.getTitusClient(account, region) this.registry = registry this.metricsSupport = new OnDemandMetricsSupport(registry, this, "${titusCloudProvider.id}:${OnDemandAgent.OnDemandType.ServerGroup}") + this.awsLookupUtil = awsLookupUtil } @Override @@ -268,6 +280,8 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { Map serverGroups = createCache() Map instances = createCache() + Map titusSecurityGroupCache = [:] + for (Job job : jobs) { def onDemandData = onDemandKeep ? onDemandKeep[Keys.getServerGroupKey(job.name, account.name, region)] : null if (onDemandData && onDemandData.attributes.cacheTime >= start) { @@ -282,8 +296,7 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { ServerGroupData data = new ServerGroupData(job, account.name, region) cacheApplication(data, applications) cacheCluster(data, clusters) - cacheServerGroup(data, serverGroups) - cacheInstances(data, instances) + cacheServerGroup(data, serverGroups, instances, titusSecurityGroupCache) } catch (Exception ex) { log.error("Failed to cache ${job.name} in ${account.name}", ex) } @@ -317,22 +330,37 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { } } - private void cacheServerGroup(ServerGroupData data, Map serverGroups) { + private void cacheServerGroup(ServerGroupData data, Map serverGroups, Map instances, Map titusSecurityGroupCache) { serverGroups[data.serverGroup].with { - attributes.job = objectMapper.convertValue(data.job, Job.class) + Job job = objectMapper.convertValue(data.job, Job.class) + resolveAwsDetails(titusSecurityGroupCache, job) + attributes.job = job attributes.tasks = data.job.tasks attributes.region = region attributes.account = account.name relationships[APPLICATIONS.ns].add(data.appName) relationships[CLUSTERS.ns].add(data.cluster) relationships[INSTANCES.ns].addAll(data.instanceIds) + for (Job.TaskSummary task : job.tasks) { + def instanceData = new InstanceData(job, task, account.name, region) + cacheInstance(instanceData, instances) + } } } - private void cacheInstances(ServerGroupData data, Map instances) { - for (Job.TaskSummary task : data.job.tasks) { - instances[Keys.getInstanceKey(task.id)].with { + private void cacheInstance(InstanceData data, Map instances) { + instances[data.instanceId].with { + Job.TaskSummary task = objectMapper.convertValue(data.task, Job.TaskSummary) + attributes.task = task + Map job = objectMapper.convertValue(data.job, Map) + job.remove('tasks') + attributes.job = job + attributes.put(HEALTH.ns, [getTitusHealth(task)]) + relationships[IMAGES.ns].add(data.imageId) + if (data.serverGroup) { relationships[SERVER_GROUPS.ns].add(data.serverGroup) + } else { + relationships[SERVER_GROUPS.ns].clear() } } } @@ -378,4 +406,41 @@ class TitusClusterCachingAgent implements CachingAgent, OnDemandAgent { } } + private void resolveAwsDetails(Map titusSecurityGroupCache, + Job job) { + Set securityGroups = awsLookupUtil.get().lookupSecurityGroupNames( + titusSecurityGroupCache, account.name, region, job.securityGroups + ) + job.securityGroupDetails = securityGroups + } + + private static class InstanceData { + private final Job job + private final Job.TaskSummary task + private final String instanceId + private final String serverGroup + private final String imageId + + public InstanceData(Job job, Job.TaskSummary task, String account, String region) { + this.job = job + this.task = task + this.instanceId = Keys.getInstanceKey(task.id) + this.serverGroup = job.name + this.imageId = "${job.applicationName}:${job.version}" + } + } + + private Map getTitusHealth(Job.TaskSummary task) { + TaskState taskState = task.state + HealthState healthState = HealthState.Unknown + if (taskState in [TaskState.STOPPED, TaskState.FAILED, TaskState.CRASHED, TaskState.FINISHED, TaskState.DEAD, TaskState.TERMINATING]) { + healthState = HealthState.Down + } else if (taskState in [TaskState.STARTING, TaskState.DISPATCHED, TaskState.PENDING, TaskState.QUEUED]) { + healthState = HealthState.Starting + } else { + healthState = HealthState.Unknown + } + [type: 'Titus', healthClass: 'platform', state: healthState.toString()] + } + } diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusInstanceCachingAgent.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusInstanceCachingAgent.groovy deleted file mode 100644 index 971be49ae65..00000000000 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/agents/TitusInstanceCachingAgent.groovy +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2016 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.netflix.spinnaker.clouddriver.titus.caching.agents -import com.fasterxml.jackson.databind.ObjectMapper -import com.netflix.spinnaker.cats.agent.AgentDataType -import com.netflix.spinnaker.cats.agent.CacheResult -import com.netflix.spinnaker.cats.agent.CachingAgent -import com.netflix.spinnaker.cats.agent.DefaultCacheResult -import com.netflix.spinnaker.cats.cache.CacheData -import com.netflix.spinnaker.cats.provider.ProviderCache -import com.netflix.spinnaker.clouddriver.model.HealthState -import com.netflix.spinnaker.clouddriver.titus.TitusClientProvider -import com.netflix.spinnaker.clouddriver.titus.client.model.Job -import com.netflix.spinnaker.clouddriver.titus.credentials.NetflixTitusCredentials -import com.netflix.spinnaker.clouddriver.titus.caching.Keys -import com.netflix.spinnaker.clouddriver.titus.caching.TitusCachingProvider -import com.netflix.spinnaker.clouddriver.titus.client.TitusClient -import com.netflix.spinnaker.clouddriver.titus.client.model.TaskState -import org.slf4j.Logger -import org.slf4j.LoggerFactory - - -import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.IMAGES -import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.INSTANCES -import static com.netflix.spinnaker.clouddriver.titus.caching.Keys.Namespace.SERVER_GROUPS -import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.AUTHORITATIVE -import static com.netflix.spinnaker.cats.agent.AgentDataType.Authority.INFORMATIVE -import static com.netflix.spinnaker.clouddriver.core.provider.agent.Namespace.HEALTH - -class TitusInstanceCachingAgent implements CachingAgent { - - private static final Logger log = LoggerFactory.getLogger(TitusClusterCachingAgent) - - final Set types = Collections.unmodifiableSet([ - AUTHORITATIVE.forType(INSTANCES.ns), - INFORMATIVE.forType(SERVER_GROUPS.ns), - INFORMATIVE.forType(IMAGES.ns) - ] as Set) - - private final TitusClientProvider titusClientProvider - private final NetflixTitusCredentials account - private final String region - private final ObjectMapper objectMapper - - TitusInstanceCachingAgent(TitusClientProvider titusClientProvider, - NetflixTitusCredentials account, - String region, - ObjectMapper objectMapper) { - this.titusClientProvider = titusClientProvider - this.account = account - this.region = region - this.objectMapper = objectMapper - } - - @Override - String getProviderName() { - TitusCachingProvider.PROVIDER_NAME - } - - @Override - String getAgentType() { - "${account.name}/${region}/${TitusInstanceCachingAgent.simpleName}" - } - - @Override - Collection getProvidedDataTypes() { - types - } - - static class MutableCacheData implements CacheData { - final String id - int ttlSeconds = -1 - final Map attributes = [:] - final Map> relationships = [:].withDefault { [] as Set } - public MutableCacheData(String id) { - this.id = id - } - } - - @Override - CacheResult loadData(ProviderCache providerCache) { - // Initialize empty caches - Closure> cache = { - [:].withDefault { String id -> new MutableCacheData(id) } - } - Map serverGroups = cache() - Map instances = cache() - Map images = cache() - - // Fetch ALL titus tasks - TitusClient titusClient = titusClientProvider.getTitusClient(account, region) - List jobs = titusClient.getAllJobs() - for (Job job : jobs) { - for (Job.TaskSummary task : job.tasks) { - def data = new InstanceData(job, task, account.name, region) - cacheImage(data, images) - cacheServerGroup(data, serverGroups) - cacheInstance(data, instances) - } - } - - new DefaultCacheResult( - (SERVER_GROUPS.ns): serverGroups.values(), - (INSTANCES.ns): instances.values(), - (IMAGES.ns): images.values() - ) - } - - private void cacheImage(InstanceData data, Map images) { - images[data.imageId].with { - relationships[INSTANCES.ns].add(data.instanceId) - } - } - - private void cacheServerGroup(InstanceData data, Map serverGroups) { - if (data.serverGroup) { - serverGroups[data.serverGroup].with { - relationships[INSTANCES.ns].add(data.instanceId) - } - } - } - - private void cacheInstance(InstanceData data, Map instances) { - instances[data.instanceId].with { - Job.TaskSummary task = objectMapper.convertValue(data.task, Job.TaskSummary) - attributes.task = task - Map job = objectMapper.convertValue(data.job, Map) - job.remove('tasks') - attributes.job = job - attributes.put(HEALTH.ns, [getTitusHealth(task)]) - relationships[IMAGES.ns].add(data.imageId) - if (data.serverGroup) { - relationships[SERVER_GROUPS.ns].add(data.serverGroup) - } else { - relationships[SERVER_GROUPS.ns].clear() - } - } - - } - - private Map getTitusHealth(Job.TaskSummary task) { - TaskState taskState = task.state - HealthState healthState = HealthState.Unknown - if (taskState in [TaskState.STOPPED, TaskState.FAILED, TaskState.CRASHED, TaskState.FINISHED, TaskState.DEAD, TaskState.TERMINATING]) { - healthState = HealthState.Down - } else if (taskState in [TaskState.STARTING, TaskState.DISPATCHED, TaskState.PENDING, TaskState.QUEUED]) { - healthState = HealthState.Starting - } else { - healthState = HealthState.Unknown - } - [type: 'Titus', healthClass: 'platform', state: healthState.toString()] - } - - private static class InstanceData { - private final Job job - private final Job.TaskSummary task - private final String instanceId - private final String serverGroup - private final String imageId - - public InstanceData(Job job, Job.TaskSummary task, String account, String region) { - this.job = job - this.task = task - this.instanceId = Keys.getInstanceKey(task.id) - this.serverGroup = job.name - this.imageId = "${job.applicationName}:${job.version}" - } - } -} diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusClusterProvider.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusClusterProvider.groovy index fe5b816ed3b..93c874e6caf 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusClusterProvider.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusClusterProvider.groovy @@ -30,7 +30,6 @@ import com.netflix.spinnaker.clouddriver.titus.caching.utils.AwsLookupUtil import com.netflix.spinnaker.clouddriver.titus.client.model.Job import com.netflix.spinnaker.clouddriver.titus.model.TitusCluster import com.netflix.spinnaker.clouddriver.titus.model.TitusInstance -import com.netflix.spinnaker.clouddriver.titus.model.TitusSecurityGroup import com.netflix.spinnaker.clouddriver.titus.model.TitusServerGroup import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @@ -156,7 +155,6 @@ class TitusClusterProvider implements ClusterProvider { serverGroup.placement.account = account serverGroup.placement.region = region serverGroup.instances = translateInstances(resolveRelationshipData(serverGroupData, INSTANCES.ns)).values() - resolveAwsDetails([:], serverGroup) serverGroup } @@ -212,13 +210,11 @@ class TitusClusterProvider implements ClusterProvider { Collection allInstances = resolveRelationshipDataForCollection(serverGroupData, INSTANCES.ns, RelationshipCacheFilter.none()) Map instances = translateInstances(allInstances) - def titusSecurityGroupCache = [:] Map serverGroups = serverGroupData.collectEntries { serverGroupEntry -> String json = objectMapper.writeValueAsString(serverGroupEntry.attributes.job) Job job = objectMapper.readValue(json, Job) TitusServerGroup serverGroup = new TitusServerGroup(job, serverGroupEntry.attributes.account, serverGroupEntry.attributes.region) serverGroup.instances = serverGroupEntry.relationships[INSTANCES.ns]?.findResults { instances.get(it) } as Set - resolveAwsDetails(titusSecurityGroupCache, serverGroup) [(serverGroupEntry.id): serverGroup] } serverGroups @@ -272,15 +268,4 @@ class TitusClusterProvider implements ClusterProvider { filteredRelationships ? cacheView.getAll(relationship, filteredRelationships) : [] } - private void resolveAwsDetails(Map titusSecurityGroupCache, - TitusServerGroup serverGroup) { - Set securityGroups = awsLookupUtil.lookupSecurityGroupNames( - titusSecurityGroupCache, serverGroup.placement.account, serverGroup.placement.region, serverGroup.securityGroups - ) - serverGroup.instances.each { - it.securityGroups = securityGroups - } - serverGroup.securityGroupDetails = securityGroups - } - } diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusInstanceProvider.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusInstanceProvider.groovy index b11918ddebe..bf966fae1c5 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusInstanceProvider.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/providers/TitusInstanceProvider.groovy @@ -23,10 +23,8 @@ import com.netflix.spinnaker.clouddriver.core.provider.agent.ExternalHealthProvi import com.netflix.spinnaker.clouddriver.model.InstanceProvider import com.netflix.spinnaker.clouddriver.titus.TitusCloudProvider import com.netflix.spinnaker.clouddriver.titus.caching.Keys -import com.netflix.spinnaker.clouddriver.titus.caching.utils.AwsLookupUtil import com.netflix.spinnaker.clouddriver.titus.client.model.Job import com.netflix.spinnaker.clouddriver.titus.model.TitusInstance -import com.netflix.spinnaker.clouddriver.titus.model.TitusSecurityGroup import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @@ -43,9 +41,6 @@ class TitusInstanceProvider implements InstanceProvider { @Autowired(required = false) List externalHealthProviders - @Autowired - AwsLookupUtil awsLookupUtil - @Autowired TitusInstanceProvider(Cache cacheView, TitusCloudProvider titusCloudProvider, ObjectMapper objectMapper) { this.cacheView = cacheView @@ -66,7 +61,6 @@ class TitusInstanceProvider implements InstanceProvider { if (instanceEntry.attributes[HEALTH.ns]) { instance.health.addAll(instanceEntry.attributes[HEALTH.ns]) } - instance.securityGroups = awsLookupUtil.lookupSecurityGroupNames([:], account, region, job.securityGroups as LinkedHashSet) externalHealthProviders.each { externalHealthProvider -> def healthKeys = [] externalHealthProvider.agents.each { externalHealthAgent -> diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/utils/AwsLookupUtil.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/utils/AwsLookupUtil.groovy index 32d5e4498b0..896fa13da70 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/utils/AwsLookupUtil.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/caching/utils/AwsLookupUtil.groovy @@ -50,7 +50,7 @@ class AwsLookupUtil { Set lookupSecurityGroupNames(Map titusSecurityGroupLookupCache, String account, String region, - LinkedHashSet securityGroups) { + List securityGroups) { Set expandedGroups = new LinkedHashSet() securityGroups.each { securityGroupId -> def titusSecurityGroupLookupCacheId = "${account}-${region}-${securityGroupId}".toString() diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/client/model/Job.java b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/client/model/Job.java index de9e33b605e..d149758d88f 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/client/model/Job.java +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/client/model/Job.java @@ -16,6 +16,8 @@ package com.netflix.spinnaker.clouddriver.titus.client.model; +import com.netflix.spinnaker.clouddriver.titus.model.TitusSecurityGroup; + import java.util.*; public class Job { @@ -189,6 +191,7 @@ public void setSnapshots(String snapshots) { private List tasks; private Map labels; private List securityGroups; + private Set securityGroupDetails; private String jobGroupStack; private String jobGroupDetail; private String jobGroupSequence; @@ -414,4 +417,8 @@ public void setTasks(List tasks) { public void setEfs(Efs efs) { this.efs = efs; } + public Set getSecurityGroupDetails() { return securityGroupDetails; } + + public void setSecurityGroupDetails(Set securityGroupDetails) { this.securityGroupDetails = securityGroupDetails; } + } diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusInstance.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusInstance.groovy index 68c82582eea..3cbf0e55b93 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusInstance.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusInstance.groovy @@ -20,7 +20,6 @@ import com.netflix.frigga.Names import com.netflix.spinnaker.clouddriver.model.HealthState import com.netflix.spinnaker.clouddriver.model.Instance import com.netflix.spinnaker.clouddriver.titus.TitusCloudProvider -import com.netflix.spinnaker.clouddriver.titus.client.model.Efs import com.netflix.spinnaker.clouddriver.titus.client.model.Job import com.netflix.spinnaker.clouddriver.titus.client.model.TaskState @@ -48,6 +47,7 @@ class TitusInstance implements Instance { TitusInstance(Job job, Job.TaskSummary task) { id = task.id instanceId = task.instanceId + securityGroups = job.securityGroupDetails jobId = job.id jobName = job.name application = Names.parseName(job.name).app diff --git a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusServerGroup.groovy b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusServerGroup.groovy index c3ae93a8b61..579ba5298dc 100644 --- a/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusServerGroup.groovy +++ b/clouddriver-titus/src/main/groovy/com/netflix/spinnaker/clouddriver/titus/model/TitusServerGroup.groovy @@ -61,6 +61,7 @@ class TitusServerGroup implements ServerGroup, Serializable { TitusServerGroup(Job job, String account, String region) { id = job.id name = job.name + securityGroupDetails = job.securityGroupDetails image << [dockerImageName: job.applicationName] image << [dockerImageVersion: job.version] entryPoint = job.entryPoint