Skip to content

Commit

Permalink
fix(google): Don't fetch image relationships (#2502)
Browse files Browse the repository at this point in the history
When listing the images for a Google account, we don't
use any of the returned cache relationships, so skip fetching
these from the cache entirely.
  • Loading branch information
ezimanyi authored Apr 11, 2018
1 parent 20ef78b commit acdb6b6
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.api.services.compute.model.Image
import com.google.common.annotations.VisibleForTesting
import com.netflix.spinnaker.cats.cache.Cache
import com.netflix.spinnaker.cats.cache.CacheData
import com.netflix.spinnaker.cats.cache.RelationshipCacheFilter
import com.netflix.spinnaker.cats.mem.InMemoryCache
import com.netflix.spinnaker.clouddriver.google.GoogleCloudProvider
import com.netflix.spinnaker.clouddriver.google.cache.Keys
Expand Down Expand Up @@ -89,10 +90,10 @@ class GoogleNamedImageLookupController {
}

Map<String, List<Image>> listImagesByAccount() {
def filter = cacheView.filterIdentifiers(IMAGES.ns, "$GoogleCloudProvider.ID:*")
def identifiers = cacheView.filterIdentifiers(IMAGES.ns, "$GoogleCloudProvider.ID:*")
def result = [:].withDefault { _ -> []}

cacheView.getAll(IMAGES.ns, filter).each { CacheData cacheData ->
cacheView.getAll(IMAGES.ns, identifiers, RelationshipCacheFilter.none()).each { CacheData cacheData ->
def account = Keys.parse(cacheData.id).account
result[account] << (cacheData.attributes.image as Image)
}
Expand Down

0 comments on commit acdb6b6

Please sign in to comment.