-
Notifications
You must be signed in to change notification settings - Fork 229
feat: external id provider for external dependent resources #2970
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
base: next
Are you sure you want to change the base?
Conversation
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Continuing the ongoing discussion from #2968: The old approach might miss the existing dependent resource if it drifts from desired externally. I hope this snippet of pseudocode can make my hypothesis clear.
This means we currently cannot get a resource from the cache if it is out of sync with the primary. This might be desirable as we might not want to rely on the caches data in this case - or it might not be because we could concurrently trigger a "create()" in some weird circumstance, thinking the resource is gone. You're new approach might then be preferable - only requiring the id to match. Could we be repurposing/moving the "keyFor(R)" method from CacheKeyMapper for this? |
not sure if following this part:
This (context.getSecondaryResources(..)) should always return ALL the related resources to the primary, since that happens based on the Line 50 in 75405bf
|
I hope I can make it more clear. The cache now contains "ID1": "B". desired(primary) still is "A"
The IDs match, and the cache has the resource, but the old implementation using |
This would not work even if you override equals on those objects? So it maches the ID that otherwise would be returned from the |
Would overriding equals like this not prevent updates from working? AbstractExternalResource.match() uses it to determine whether it needs to call update() on the resource, iirc. |
As I said, I believe we could use the CacheKeyMapper interface instead of introducing a new one. We might want to rename it though. |
That is not true, this is just to selecting the target resource from cache, later there is a separate matching phase. |
That is tempting, let me get back to this a bit later. |
Line 91 in 75405bf
Is this the matching phase you mentioned? I was referring to this. |
Hmm yes, that is true, that is meant to be overridden, we might want to have ti abstract in the future. But true, the default implementation is confusing this way. Yes, so you have to override that part. Will take a look how could we make this nicer in the defatult setup. |
Cool, thanks a lot for the collaboration. Just general feedback from me as a new user: I currently find it hard to determine what is meant to be overridden. I want to get the most out of the framework so I tend to leave defaults intact. Your input helps a ton, though. I've had a lot of progress with just these few back-and-forth messages. Thanks again for the support! |
Thank you! yes, we will improve this for 5.2 soon definitely, so it is obvious how to handle this for users. Will create a separate an umbrella issue that has a summary of the problem a proposal how to handle it. thx again for the feedback and pointing this out!! |
@florianknecht pls see also related issue: #2972 |
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@florianknecht @metacosm @xstefank this is now ready for review. We might want to iterate more (separate PRs) on the cache keys and external resource states etc. |
docs/content/en/docs/documentation/dependent-resource-and-workflows/dependent-resources.md
Outdated
Show resolved
Hide resolved
docs/content/en/docs/documentation/dependent-resource-and-workflows/dependent-resources.md
Outdated
Show resolved
Hide resolved
} else { | ||
throw new IllegalStateException( | ||
"Either implement ExternalDependentIDProvider or override" | ||
+ " selectTargetSecondaryResource."); |
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.
+ " selectTargetSecondaryResource."); | |
+ " AbstractDependentResource#selectTargetSecondaryResource."); |
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.
since this is thrown from the method selectTargetSecondaryResource
this might be more confusing than now
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 would appreciate to point where to find what I need to override but I'm ok with leaving it as is.
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 updated the message to articulate that it is about "this", the method from which the exception is thrown.
.../main/java/io/javaoperatorsdk/operator/processing/dependent/ExternalDependentIDProvider.java
Outdated
Show resolved
Hide resolved
…flows/dependent-resources.md Co-authored-by: Martin Stefanko <xstefank122@gmail.com>
…tor/processing/dependent/ExternalDependentIDProvider.java Co-authored-by: Martin Stefanko <xstefank122@gmail.com>
Would be nice to update the MySQL sample to manage updates, can do it later, or as a separate PR. |
@metacosm can I merge this? |
This is the rough idea how to make the selection of target external dependent resources more visible.