-
Notifications
You must be signed in to change notification settings - Fork 218
eventing refinements mentioned on #2012 #2034
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
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
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be >0
I guess
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a javadoc
} | ||
} catch (NumberFormatException e) { | ||
log.debug( | ||
"Could not compare resourceVersions {} and {} for {}", |
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 be this a warning? even if it could pollute cache? (no strong opinion)
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.
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.
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 mean pollute logs :)
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 <[email protected]>
03d423d
to
1380caa
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, a more explicit method name would be better, imo.
default boolean parseResourceVersions() { | |
default boolean useResourceVersionsForEventOrdering() { |
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.
Let's decide if you even want this before making a name change.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -364,4 +364,31 @@ default Set<Class<? extends HasMetadata>> defaultNonSSAResource() { | |||
return Set.of(ConfigMap.class, Secret.class); | |||
} | |||
|
|||
/** | |||
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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 <[email protected]>
@@ -78,14 +80,31 @@ public class InformerEventSource<R extends HasMetadata, P extends HasMetadata> | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document what are the situations this is solving
Signed-off-by: Attila Mészáros <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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 <[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]>
* 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]>
* 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]>
provides two options
Looking for feedback on if these are the right places to introduce the configuration.