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(kubernetes): Fix all agents caching cluster-scoped resources #4128

Merged
merged 6 commits into from
Oct 29, 2019
Merged

fix(kubernetes): Fix all agents caching cluster-scoped resources #4128

merged 6 commits into from
Oct 29, 2019

Conversation

ezimanyi
Copy link
Contributor

  • refactor(kubernetes): Minor refactor of core caching agent test

    Pull some common logic out of ProcessOnDemandResult so that it can be reused when we need to process the results of a loadData request in an upcoming commit.

  • test(kubernetes): Add tests to loadData in core caching agent

    There are no tests of loadData() in the KubernetesCoreCachingAgent; add a simple test that validates a namespaced and cluster-scoped kind can be succesfully cached (ie, is returned from loadData and is persisted to the cache).

  • refactor(kubernetes): Immutable collections and nonnull annotations

    Make a few collections returned by the kubernetes caching agent immutable, and add some nonnull annotations that simplify the work of calling code.

  • refactor(kubernetes): Split caching of resources by scope

    This commit splits the work to cache kubernetes objects into two functions: the first caches namespace-scoped objects for all namespaces relevant for the caching agent, and the second caches all cluster-scoped resources.

    This means that we'll no longer try to read the cluster-scoped resources once per namespace and will read them once per caching agent.

  • fix(kubernetes): Fix all agents caching cluster-scoped resources

    Currently all caching agents are caching cluster-scoped resources; this should be delegated to a single agent so that we don't duplicate work.

Pull some common logic out of ProcessOnDemandResult so that it can
be reused when we need to process the results of a loadData request
in an upcoming commit.
There are no tests of loadData() in the KubernetesCoreCachingAgent;
add a simple test that validates a namespaced and cluster-scoped
kind can be succesfully cached (ie, is returned from loadData and
is persisted to the cache).
Make a few collections returned by the kubernetes caching agent
immutable, and add some nonnull annotations that simplify the
work of calling code.
This commit splits the work to cache kubernetes objects into two
functions: the first caches namespace-scoped objects for all
namespaces relevant for the caching agent, and the second caches
all cluster-scoped resources.

This means that we'll no longer try to read the cluster-scoped
resources once per namespace and will read them once per caching
agent.
Currently all caching agents are caching cluster-scoped resources;
this should be delegated to a single agent so that we don't duplicate
work.
Copy link
Member

@plumpy plumpy left a comment

Choose a reason for hiding this comment

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

🍡 🐶 🤙

Copy link
Contributor

@maggieneterval maggieneterval left a comment

Choose a reason for hiding this comment

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

⛏️ 🕵️‍♂️ 🕵️‍♀️ 📦 🍬 💰

.extracting(data -> data.getAttributes().get("name"))
.containsExactly(STORAGE_CLASS_NAME);

assertThat(loadDataResult.getResults()).containsKey(DEPLOYMENT_KIND);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we have this assertion twice (once on line 496 and once here)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I had intended one set of assertions to check that the return value of loadData had the expected entries, and the other set to check that the cache actually contained the expected entries, but was checking the return value in both.

When trying to add the assertion on the contents of the cache, I realized that loadData doesn't actually update the cache itself---the return value is used by another function to actually update the cache. So I just removed the duplicate set of assertions, as updating the cache is not part of loadData's contract.

@@ -19,6 +19,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSetMultimap;
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoah, new favorite Pokemon!

I had intended the second set of assertions to be testing the
contents of the cache. But it loadData doesn't actually
update the cache (it just returns results to an outer function that
stores the result) so we can't test that the cache is updated after
calling loadData. Just remove the extra assertions.
@ezimanyi ezimanyi merged commit 6ab4288 into spinnaker:master Oct 29, 2019
@ezimanyi ezimanyi deleted the fix-cluster-scoped-caching branch October 29, 2019 17:27
tomaslin pushed a commit to tomaslin/clouddriver that referenced this pull request Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants