Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(google): don't leave orphaned applications in the cache #4123

Merged
merged 3 commits into from
Oct 28, 2019

Conversation

plumpy
Copy link
Member

@plumpy plumpy commented Oct 25, 2019

If an AbstractGoogleServerGroupCachingAgent has some applications stored,
but in the next run it finds no applications, it doesn't put anything
under the applications key. DefaultProviderCache then has some weird
behavior where it removes all relationships associated with that
application, but leaves the existing application in the cache. That
means we'll just repeat that behavior again the next time the caching
agent runs. The application data is just orphaned but triggers
relationship evictions every single caching cycle.

Amazon doesn't have this problem because they always stick a
List<CacheData> under the applications key, even if it's empty. This is
enough to tell putCacheResult() to store that empty list, overwriting
whatever was there before.

The orphaned data isn't the cause of spinnaker/spinnaker#4511, but it
dramatically exacerbates that issue. (The real issue is that every
single regional/zonal caching agent asserts ownership over the
application and will happily delete it, which triggers deletions of
relationships that were put there by other caching agents.)

I was working on a larger refactor of CATS to make this bug less likely
to happen, but since we're about to cut a release branch, I'd rather
just check in this smaller fix.

If a AbstractGoogleServerGroupCachingAgent has some applications stored,
but in the next run it finds no applications, it doesn't put anything
under the "applications" key. DefaultProviderCache then has some weird
behavior where it removes all relationships associated with that
application, but leaves the existing application in the cache. That
means we'll just repeat that behavior again the next time the caching
agent runs. The application data is just orphaned but triggers
relationship evictions every single caching cycle.

Amazon doesn't have this problem because they always stick a
List<CacheData> under the applications key, even if it's empty. This is
enough to tell putCacheResult() to store that empty list, overwriting
whatever was there before.

The orphaned data isn't the cause of spinnaker/spinnaker#4511, but it
dramatically exacerbates that issue. (The real issue is that every
single regional/zonal caching agent asserts ownership over the
application and will happily delete it, which triggers deletions of
relationships that were put there by other caching agents.)

I was working on a larger refactor of CATS to make this bug less likely
to happen, but since we're about to cut a release branch, I'd rather
just check in this smaller fix.
@plumpy plumpy requested a review from duftler October 25, 2019 18:27
.setAttributes(ImmutableMap.of("attr3", "value3"));

Map<String, Collection<CacheData>> cacheResults = cacheResultBuilder.build().getCacheResults();
assertThat(cacheResults.get("auth1")).isEmpty();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link

@duftler duftler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@plumpy plumpy merged commit 64197ce into spinnaker:master Oct 28, 2019
@plumpy plumpy deleted the cache_result_builder_specify_types branch October 28, 2019 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants