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

Update resource cache after update/create from Dependent Resource #953

Closed
wants to merge 13 commits into from

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Feb 17, 2022

No description provided.

@csviri csviri changed the base branch from main to next February 17, 2022 09:52
@csviri csviri changed the title Dr up to date get resource Update resource cache after update/create from Dependent Resource Feb 17, 2022
@@ -39,4 +40,8 @@ public void stop() {
super.stop();
manager().stop();
}

public void populateCacheUpdatedResource(R resource) {
cache.put(ResourceID.fromResource(resource), resource);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on fabric8io/kubernetes-client#3654 (comment), I'm not sure we should be modifying the informer's cache :(
Another thing is that this won't be possible in 6.0 anymore so we need to think about an alternative, in particular in the light of: fabric8io/kubernetes-client#3616. So we might have to think about re-adding our own caching layer sooner than later…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the plan is to do it with the separate cache if the informers will be modified for that. Not sure if we can get away with this until that time. It's not 100% correct, but the chance to have there a race condition is very close to zero

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

An alternative is to wait for the event that the cache received the resource with the resource version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would mean not the update/delete would propagate the cache but the getResource() will be kinda "synchronous"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Solved it in a different way, pls see updated PR. (Will add unit tests soon)

@csviri csviri self-assigned this Feb 17, 2022
# Conflicts:
#	operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/standalonedependent/StandaloneDependentTestReconciler.java
@csviri csviri marked this pull request as ready for review February 18, 2022 09:11
@csviri csviri requested a review from metacosm February 18, 2022 14:18
# Conflicts:
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java
@sonarcloud
Copy link

sonarcloud bot commented Feb 21, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 20 Code Smells

32.5% 32.5% Coverage
0.5% 0.5% Duplication

@metacosm
Copy link
Collaborator

I'm thinking that this work should be integrated in the InformerResourceCache layer instead of a separate layer that needs to be managed by, and therefore only useful to, KubernetesDependentResource. This would make the functionality available even for people not using KubernetesDependentResource and solve the problematic informer cache update that's currently performed by InformerResourceCache in a neat way. What do you think?

@csviri
Copy link
Collaborator Author

csviri commented Feb 21, 2022

The thing is that this is not needed when you work directly with resources, since when a resource is created by the client a new object is returned that users can work with further. So it us really useful for dependent resources. Since the getResource() is called eventually by other dependent resource.

Plan is to put it there yes, after the cache layer will be separated from informers, as mentioned by @shawkins; for an upcoming version of informers. So for now I would just merge this, and create a followup issue.

Putting this updated resource now to cache of the informers has race condition issues, that are not nicely solvable now.

@csviri
Copy link
Collaborator Author

csviri commented Feb 21, 2022

just a remark this issue I actually plan to put into informer event source: #870

It's kinda similar to this. So we can revisit also there. Not sure we need this to MVP though, maybe right after?

@csviri
Copy link
Collaborator Author

csviri commented Feb 21, 2022

Hmm, actually you are right, can take a look, and move the temporal layer to the event source. now this impl looks quite different then on begging. Maybe would be able to implement also the mentioned issue in a simple way.

@csviri
Copy link
Collaborator Author

csviri commented Feb 23, 2022

this PR is replaced by: #965

@csviri csviri closed this Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants