eventing refinements mentioned on #2012#2034
Conversation
|
@shawkins could you pls rebase this PR? |
2bdd8f9 to
e9c2639
Compare
It's up-to-date now. |
8e724e3 to
1ae5efa
Compare
csviri
left a comment
There was a problem hiding this comment.
Just some minor issues with current code. I'm aware that it is WIP
| && ((InformerConfiguration) managedInformerEventSource.getInformerConfiguration()) | ||
| .parseResourceVersions() | ||
| && Long.compare(Long.parseLong(newResource.getMetadata().getResourceVersion()), | ||
| Long.parseLong(cachedResource.getMetadata().getResourceVersion())) > 1) { |
There was a problem hiding this comment.
Thanks, corrected.
...n/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java
Outdated
Show resolved
Hide resolved
| T cachedResource = cache.get(resourceId); | ||
|
|
||
| if (unknownState || (cachedResource != null | ||
| && !isLaterResourceVersion(resourceId, cachedResource, resource))) { |
There was a problem hiding this comment.
Kinda makes this code hard to read that the feature flag is checked inside the isLaterResourceVersion, would extract on a level above or rename this function to denote that fact.
There was a problem hiding this comment.
Will add a javadoc
| } | ||
| } catch (NumberFormatException e) { | ||
| log.debug( | ||
| "Could not compare resourceVersions {} and {} for {}", |
There was a problem hiding this comment.
Shouldn't be this a warning? even if it could pollute cache? (no strong opinion)
There was a problem hiding this comment.
It won't pollute the cache, it would exhibit the same behavior as it does now. It can of course be at whatever level you want.
1ae5efa to
535add0
Compare
No problem. Made some changes to address those concerns. What about the methods for configuration hooks - are those in the right places and how far up would that need to be exposed? |
I think both should be in configuration service, some of the properties we want to configure also on DR level, like if it should use SSA (I will do a separate PR), but not there two IMO |
535add0 to
8c412f7
Compare
0cc0f5a to
181eb31
Compare
|
@csviri rebased and further refined the configuration. If this looks good I'll add some tests. |
sure looks good imo |
181eb31 to
de90854
Compare
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 <shawkins@redhat.com>
03d423d to
1380caa
Compare
metacosm
left a comment
There was a problem hiding this comment.
More generally speaking, shouldn't the event skipping be handled at the ManagedInformerEventSource level instead of in the InformerEventSource? In particular, wouldn't it make sense to handle the resource versions in the temporary cache as well?
| * | ||
| * @since 4.5.0 | ||
| */ | ||
| default boolean previousAnnotationForDependentResources() { |
There was a problem hiding this comment.
I would rather see a more explicit method name that conveys better the intent, i.e. something like:
| default boolean previousAnnotationForDependentResources() { | |
| default boolean processOwnDependentResourceUpdates() { |
There was a problem hiding this comment.
Since there have been multiple mechanism for this the thinking is to use specific rather than general terminology, so that if it changes again the user can be explicit about which mechanism(s) are in play.
If you strongly prefer the general feature name, that's fine too.
There was a problem hiding this comment.
I think this would be too generic.
previousAnnotationForDependentResourcesEventFiltering or somethink would make more sense to me.
| * | ||
| * @since 4.5.0 | ||
| */ | ||
| default boolean parseResourceVersions() { |
There was a problem hiding this comment.
Similarly, a more explicit method name would be better, imo.
| default boolean parseResourceVersions() { | |
| default boolean useResourceVersionsForEventOrdering() { |
There was a problem hiding this comment.
Let's decide if you even want this before making a name change.
There was a problem hiding this comment.
In general I'm not against this. Also would stick with the original name, thus parseResourceVersions since this can have later effect on other parts.
There was a problem hiding this comment.
parseResourceVersions doesn't mean anything to me as a user… Parse how? For what purpose? Why would I care? Sure, this can be mitigated by documentation but as we know documentation is not always up to date and I'd rather have explicit method names for user-facing options.
| } | ||
|
|
||
| /** | ||
| * If an annotation should be used so that the operator sdk can detect events from its own updates |
There was a problem hiding this comment.
Using an annotation is an implementation detail towards achieving filtering of own updates. If we want to explain that an annotation is used for this purpose, either we need to document in greater details how the annotation is used (so that users can actually use that information) or not mention it at all, imo.
There was a problem hiding this comment.
Other than specifying what the annotation name is, there isn't much greater detail that is needed here - the user is not expected to do anything with these annotations.
There was a problem hiding this comment.
Yes, I think it would make sense to document the annotation name so that people can look it up in case people notice it in their resources and wonder what that is.
| * is typically not needed. | ||
| * <p> | ||
| * Disabled by default as Kubernetes does not support, and discourages, this interpretation of | ||
| * resourceVersions. Enable only if your api server event processing seems to lag the operator |
There was a problem hiding this comment.
Maybe a more concrete example of when setting this to true would help. As is, it's not obvious when people might want to use this and I would rather not expose this at all if this isn't sufficiently / broadly applicable.
There was a problem hiding this comment.
It's basically for feature parity with the mutable cache that is in go client - I'm not aware of user request for the feature, so if you feel strongly about it, then it could be hidden or removed.
Event skipping (filtering or event recording / previous annotation) was already being handled at the InformerEventSource level, this is really just another case to consider.
I had considered that, but it didn't initially make sense given the other code structure. Now that does make more sense because parseResourceVersions is passed into the TemporaryCache constructor. |
Signed-off-by: Attila Mészáros <csviri@gmail.com>
| private final PrimaryToSecondaryMapper<P> primaryToSecondaryMapper; | ||
| private Map<String, Function<R, List<String>>> indexerBuffer = new HashMap<>(); | ||
| private final String id = UUID.randomUUID().toString(); | ||
| private final Set<String> knownResourceVersions; |
There was a problem hiding this comment.
Please document what are the situations this is solving
|
I like the way it is, just we need to document every change / feature in the PR since it might be hard to follow after time the corner case situatios. But otherwise looks good. |
@metacosm @csviri made updates based upon the feedback. The config names are now both similar. These are independent of one another, so we're not introducing additional interations. It really is as simple as the annotation will help filter events that come too quickly, and parsing resource versions will help with filtering and cache consistency with events that come too slowly. |
c5720f0 to
93d9ed2
Compare
...ramework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java
Outdated
Show resolved
Hide resolved
| * | ||
| * @since 4.5.0 | ||
| */ | ||
| default boolean parseResourceVersionsForDependentResourcesEventFilteringAndCaching() { |
There was a problem hiding this comment.
This kind of a parsing and caching could be done also for the primary resource. For that reason would like to omit that this is specific for the dependent resources, and just maybe add it to the description now.
|
The tests are also failing consistently so something is fishy there. |
PreviousAnnotationDisabledIT is new. It may need some additional waiting to hit the expectation. I can take a look. UPDATE: PreviousAnnotationDisabledIT can't have a single hard expectation on the number of executions - if the event arrives quickly an additional reconciliation is triggered. However if the event arrives slowly, then the comparison with the temporary resource cache item will cause the event to be skipped. So I just added a min and max for now. |
bc613f1 to
905ac9d
Compare
moving handling of known resource versions, and making the config names more descriptive Signed-off-by: Steve Hawkins <shawkins@redhat.com>
905ac9d to
8f00c93
Compare
|
The remaining test failure is already called out as #2043 |
* 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 <shawkins@redhat.com>
…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 <shawkins@redhat.com>
* 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 <shawkins@redhat.com>
* 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 <shawkins@redhat.com>
* 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 <shawkins@redhat.com>
provides two options
Looking for feedback on if these are the right places to introduce the configuration.