Skip to content

Commit 417bb12

Browse files
committed
fix: event filtering edge case with no-op updates
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent fcf5740 commit 417bb12

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,20 @@ public void changeNamespaces(Set<String> namespaces) {
9494
* reconciliation.
9595
*/
9696
@SuppressWarnings("unchecked")
97-
public R eventFilteringUpdateAndCacheResource(R resourceToUpdate, UnaryOperator<R> updateMethod) {
97+
public R eventFilteringUpdateAndCacheResource(
98+
R resourceToUpdate, UnaryOperator<R> updateOperation) {
99+
if (resourceToUpdate.getMetadata().getResourceVersion() == null) {
100+
log.debug("No resourceVersion set. Skipping event filtering.");
101+
return updateAndCacheResource(resourceToUpdate, updateOperation);
102+
}
103+
98104
ResourceID id = ResourceID.fromResource(resourceToUpdate);
99105
log.debug("Starting event filtering and caching update for id={}", id);
100106
R updatedResource = null;
101107
Set<ResourceID> relatedPrimaryIds = null;
102108
try {
103109
temporaryResourceCache.startEventFilteringModify(id);
104-
updatedResource = updateMethod.apply(resourceToUpdate);
110+
updatedResource = updateOperation.apply(resourceToUpdate);
105111
relatedPrimaryIds = cacheUpdateAndGetRelatedPrimaryIDs(updatedResource, resourceToUpdate);
106112
log.debug(
107113
"Caching resource update successful. id={}, rv={}",
@@ -134,6 +140,12 @@ public R eventFilteringUpdateAndCacheResource(R resourceToUpdate, UnaryOperator<
134140
}
135141
}
136142

143+
private R updateAndCacheResource(R resourceToUpdate, UnaryOperator<R> updateOperation) {
144+
var result = updateOperation.apply(resourceToUpdate);
145+
handleRecentResourceUpdate(ResourceID.fromResource(resourceToUpdate), result, resourceToUpdate);
146+
return result;
147+
}
148+
137149
protected abstract void handleEvent(
138150
ResourceAction action,
139151
R resource,

0 commit comments

Comments
 (0)