-
Notifications
You must be signed in to change notification settings - Fork 218
changes to simplify the recording mechanism #2012
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
To move this out of draft there are a couple of things to cover:
|
Can we rebase this so that only the relevant changes show up in the diffs, please? |
16fcfe1
to
6d26bd7
Compare
Good question, I think that could be there but we can add it a separate pull request, would we add separate one for caching and one for event propagation? |
I think there should be related IT which we might to update to check if there are annotations present, and unit tests yes. |
We have a couple of inter-related features here.
The relevant options could be:
|
0c686c7
to
3d45031
Compare
Ok, this should be considered out of draft. The integration test should work again based upon using a dependent resource instead - although it may look too hackish. |
d9de99a
to
aacd5c6
Compare
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.
LGTM
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 have more changes that I think could clean some things up but I'd need access to push to your branch. Also, I think we need some kind of documentation on this change, in particular regarding the logic used to detect whether a change has already been processed.
More generally speaking, it seems like this behavior is only limited to Kubernetes dependents. Is that really true? What happens for informer-based events which are not coming from dependents?
...n/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java
Outdated
Show resolved
Hide resolved
Maintainer access was checked.
In rough terms the annotation is being used to detect when you recieve an event ahead of when your blocking create/update call returns. If you have already moved ahead to a temporarily cached resource, or anything about your local state does not still match what is in the annotation value, we'll assume the event is needed. @csviri has suggested using another issue / pr to use a flag for this optimization. If disabled and the matching logic isn't being tripped up, then it's not a big deal to initiate another reconciliation cycle. I'm not sure what a good place is to document this, or if it should just wait for the issue that makes the feature conditional.
There are two things working together here, the KubernetesDependentResource and the InformerEventSource. That is really no different than before - only the KubernetesDependentResource had the calls to event filtering logic. Are you asking about the case of someone creating their own dependent like resource using the methods like InformerEventSource.prepareForCreateOrUpdateEventFiltering? You could still expose something like that here, you would just need different signatures as they would need to be responsible for adding the annotation and so need access to the previous revision.
Answering my own previous question - if someone were using a custom matcher and expecting labelAndAnnotation equality, then yes this new annotation would be a problem. |
a109e21
to
736ac47
Compare
.get(InformerEventSource.PREVIOUS_ANNOTATION_KEY); | ||
Map<String, String> annotations = desired.getMetadata().getAnnotations(); | ||
if (actual != null) { | ||
if (annotations == null) { |
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 don't think that we need that part as the client always make sure the annotations exist, if I'm not mistaken. Unless, of course, we want to safeguard here, regardless of what the client does.
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.
The client will initialize the annotation, but the desired is coming from the user logic (in the ssa case or if overriding the update matcher) and could have been set to null. I was just trying to match a similar guard that is used in addDefaultSecondaryToPrimaryMapperAnnotations - but I'd be fine if the assumption was that the user must leave the annotations as non-null and remove the initialization from both of those places.
Also it may not need to be part of these changes, but it's making things more complicated than needed to diffentiate the ssa and non-ssa cases wrt methods like addReferenceHandlingMetadata - I think this should be refactored so that the update / match logic can read more like create so that we'll take the same pre-steps in both cases.
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.
@metacosm see what you think of latest commit
uses an annotation and knowledge of the resourceVersion to track early events instead
and removing the locking change that will be handled via a separate pr
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly)
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly)
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly)
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly)
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly)
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly)
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
* refinements mentioned on #2012 provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
* refinements mentioned on #2012 provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]> Signed-off-by: Steve Hawkins <[email protected]>
…ramework#2034) * refinements mentioned on operator-framework#2012 provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steve Hawkins <[email protected]>
* refinements mentioned on #2012 provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steven Hawkins <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
* refinements mentioned on #2012 provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steven Hawkins <[email protected]>
Co-authored-by: Attila Mészáros <[email protected]> Co-authored-by: Chris Laprun <[email protected]> Signed-off-by: csviri <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
* refinements mentioned on #2012 provides two options - to control if the annotation is used (to omit events that come too quickly) - to parse the resource version (to keep the cache up-to-date and omit events if they come too slowly) Signed-off-by: Steven Hawkins <[email protected]>
Retargeting of #2005