-
Notifications
You must be signed in to change notification settings - Fork 218
feat: bounded cache for informers #1718
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
Conversation
c4ffb56
to
1dbe752
Compare
5aefd80
to
4af2cc5
Compare
a35083d
to
fd65df4
Compare
fe820ca
to
55f5d0b
Compare
fd65df4
to
dba990f
Compare
c03cd5a
to
63c30ed
Compare
@@ -72,6 +72,7 @@ | |||
<directory-maven-plugin.version>1.0</directory-maven-plugin.version> | |||
<impsort-maven-plugin.version>1.8.0</impsort-maven-plugin.version> | |||
<okhttp.version>4.10.0</okhttp.version> | |||
<caffein.version>3.1.3</caffein.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything caffeine-related should be named appropriately i.e. caffeine
(with an e
at the end)
@@ -122,4 +123,23 @@ default Set<String> getEffectiveNamespaces() { | |||
} | |||
return targetNamespaces; | |||
} | |||
|
|||
/** | |||
* See <a href= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a better documentation, especially considering that the link doesn't actually provide any information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
synchronized (this) { | ||
log.debug("Fetched resource: {}", newRes); | ||
if (newRes == null) { | ||
existingMinimalResources.remove(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also remove the associated object from the cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will revisit this, came to my mind that there an case, where the current impl might be a problem of this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made an update for this, to be absolutely safe
} | ||
|
||
/** | ||
* This would not be needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a leftover, removed.
8c801ae
to
c4647a1
Compare
// If received we just return. Since the resource from informer should be always leading, | ||
// even if the fetched resource is null, this will be eventually received as an event. | ||
if (actual == null) { | ||
existingMinimalResources.remove(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that actual
should be removed from cache
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
its checked 2 lines above if it's there, and that operation is synchronized
with other operation for that cache. It is not possible to put that item into the cache meanwhile.
...amework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ResourceConfiguration.java
Show resolved
Hide resolved
...amework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ResourceConfiguration.java
Show resolved
Hide resolved
08caef2
to
226be1e
Compare
226be1e
to
50e351a
Compare
Kudos, SonarCloud Quality Gate passed! |
* feat: bounded cache for informers (#1718) * fix: typo caffein -> caffeine (#1795) * feat: now possible to only output non-resource related metrics Fixes #1812. * refactor: extract abstract test fixture to add tests with variations * fix: add missing annotation * tests: add more test variations * fix: make operator non-static so it's registered once per test subclass * feat: introduce builder for MicrometerMetrics, fix test * fix: exclude more tags when not collecting per resource * fix: registry should be per-instance to ensure test independence * fix: make sure we wait a little to ensure event is properly processed * fix: make things work on Java 11, format * fix: also clean metrics on finalizer removal This is needed because the finalizer will trigger a reconciliation that adds a resource-specific metric. * fix: format * refactor: extract common tags Co-authored-by: Sébastien CROCQUESEL <88554524+scrocquesel@users.noreply.github.com> * feat: make per-resource collecting finer-grained We now still collect GVK information when per-resource collection is switched off. * fix: do not create tag for group if not present * fix: remove unreliable no-delay implementation, defaulting to 1s delay * refactor: renamed & documented factory methods to make things clearer * docs: updated metrics section for code changes * feat: avoid emitting tag on empty value * docs: update * fix: format [skip ci] * refactor: use Tag more directly, avoid unneeded work, use constants * fix: change will happen instead of might * docs: add missing timer Co-authored-by: Sébastien CROCQUESEL <88554524+scrocquesel@users.noreply.github.com> * docs: fix wrong & missing information * refactor: add constants * fix: wording [skip ci] Co-authored-by: Attila Mészáros <csviri@gmail.com> --------- Co-authored-by: Attila Mészáros <csviri@gmail.com> Co-authored-by: Sébastien CROCQUESEL <88554524+scrocquesel@users.noreply.github.com>
No description provided.