Skip to content

Commit 9db9e8e

Browse files
authored
fix: improved debig logging for getting from cache (#1725)
1 parent ae43b3b commit 9db9e8e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSource.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,17 @@ private void propagateEvent(R object) {
206206
public Set<R> getSecondaryResources(P primary) {
207207
Set<ResourceID> secondaryIDs;
208208
if (useSecondaryToPrimaryIndex()) {
209+
var primaryResourceID = ResourceID.fromResource(primary);
209210
secondaryIDs =
210-
primaryToSecondaryIndex.getSecondaryResources(ResourceID.fromResource(primary));
211+
primaryToSecondaryIndex.getSecondaryResources(primaryResourceID);
212+
log.debug(
213+
"Using PrimaryToSecondaryIndex to find secondary resources for primary: {}. Found secondary ids: {} ",
214+
primaryResourceID, secondaryIDs);
211215
} else {
212216
secondaryIDs = primaryToSecondaryMapper.toSecondaryResourceIDs(primary);
217+
log.debug(
218+
"Using PrimaryToSecondaryMapper to find secondary resources for primary: {}. Found secondary ids: {} ",
219+
primary, secondaryIDs);
213220
}
214221
return secondaryIDs.stream().map(this::get).flatMap(Optional::stream)
215222
.collect(Collectors.toSet());

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ public Optional<R> get(ResourceID resourceID) {
107107
} else {
108108
log.debug("Resource not found in temporary cache reading it from informer cache," +
109109
" for Resource ID: {}", resourceID);
110-
return cache.get(resourceID);
110+
var res = cache.get(resourceID);
111+
log.debug("Resource found in cache: {} for id: {}", res.isPresent(), resourceID);
112+
return res;
111113
}
112114
}
113115

0 commit comments

Comments
 (0)