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

Use cached discovery interface #1422

Merged
merged 8 commits into from
Mar 23, 2020
Merged

Use cached discovery interface #1422

merged 8 commits into from
Mar 23, 2020

Conversation

ANeumann82
Copy link
Member

Signed-off-by: Andreas Neumann aneumann@mesosphere.com

What this PR does / why we need it:
Using the non-cached version introduces a ~1 second delay on every call to isNamespaced, including ObjectKeyFromObject.

Fixes #1421

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

Minor logging nit but otherwise LGTM! 🚢 (provided all tests are green)

// Fetch namespaced API resources
_, apiResources, err := di.ServerGroupsAndResources()
if err != nil {
return false, fmt.Errorf("failed to fetch server groups and resources: %v", err)
if err == memory.ErrCacheNotFound {
di.Invalidate()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a logging line here so we could track cache misses.

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
…esources from DiscoveryInterface

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

we can use the same discovery.DiscoveryInterface and change the impl

@@ -58,7 +58,7 @@ import (
// Reconciler reconciles an Instance object.
type Reconciler struct {
client.Client
Discovery discovery.DiscoveryInterface
Discovery discovery.CachedDiscoveryInterface
Copy link
Member

Choose a reason for hiding this comment

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

we can use the same discovery.DiscoveryInterface and change the impl

Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

offline conversation summary:
It seems best to not force cache retry checks on all users of discovery. We should provide our own impl that implements DiscoveryInterface and delegates to memory cache and handles the logic we are looking for... assuming that is the logic we consistently desired.

@kensipe
Copy link
Member

kensipe commented Mar 18, 2020

@ANeumann82 I'm not sure where this PR stands... it looks like #1423 might have done what we were looking for. If not.. this needs to be rebased. Can we close this?

@zen-dog
Copy link
Contributor

zen-dog commented Mar 19, 2020

@ANeumann82 I'm not sure where this PR stands... it looks like #1423 might have done what we were looking for. If not.. this needs to be rebased. Can we close this?

#1423 alleviate the problem but we'll still need caching there. I'd rather we come to an agreement or agree-to-disagree and use CachedDiscoveryInterface as it already brings the needed performance improvement.

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>

# Conflicts:
#	pkg/engine/resource/object_key.go
#	pkg/test/step_test.go
@ANeumann82
Copy link
Member Author

@kensipe I've merged master, so this should be up-to-date.

I agree with @zen-dog that we probably need caching, and I do agree that we shouldn't hide Caching in a DiscoveryInterface - having the CachedDiscoveryInterface makes it very clear that this thing is caching and you'll have to think about it. This seems to be the most usable solution to me at the time.

Another option would be to have a custom caching for the isNamespaced layer, but I don't think that would make it easier to understand or to develop.

I've created a ticket #1433 where we should look into metrics to keep these things checked in future testing.

Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

I'm in agreement with @zen-dog as well.

@ANeumann82 ANeumann82 merged commit dc74924 into master Mar 23, 2020
@ANeumann82 ANeumann82 deleted the an/use-cached-discovery branch March 23, 2020 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isNamespaced check in Enhancer
3 participants