Skip to content

Commit 6ad950b

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 41c7ddf commit 6ad950b

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,13 @@ private PostExecutionControl<P> handleCleanup(
342342
}
343343

344344
private P patchResource(Context<P> context, P resource, P originalResource, boolean filterEvent) {
345-
log.debug(
346-
"Updating resource: {} with version: {}; SSA: {}",
347-
getUID(resource),
348-
getVersion(resource),
349-
useSSA);
345+
if (log.isDebugEnabled()) {
346+
log.debug(
347+
"Updating resource: {} with version: {}; SSA: {}",
348+
resource.getMetadata().getName(),
349+
getVersion(resource),
350+
useSSA);
351+
}
350352
log.trace("Resource before update: {}", resource);
351353

352354
final var finalizerName = configuration().getFinalizerName();

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,22 @@ public boolean onAddOrUpdateEvent(T resource) {
105105

106106
private boolean onEvent(T resource, boolean unknownState) {
107107
var resourceId = ResourceID.fromResource(resource);
108+
// todo move to trace these log messages
109+
log.debug(
110+
"Processing event for resource id: {} version: {} ",
111+
resourceId,
112+
resource.getMetadata().getResourceVersion());
108113
ReentrantLock lock = activelyModifying.get(resourceId);
109114
if (lock != null) {
115+
log.debug("Lock for event filtering resource id: {}", resourceId);
110116
// note that this is a special case of lock striping; event handling happens
111117
// always on the same thread of the informer we lock only if the update is happening
112118
// for the same resource (not any resource), and if the event comes from the current update
113119
// this should be locked for a very short time, since that update request already send at this
114120
// point.
115121
lock.lock(); // wait for the modification to finish
116122
lock.unlock(); // simply unlock as the event is guaranteed after the modification
123+
log.debug("Unlock for event resource id: {}", resourceId);
117124
}
118125
boolean[] filter = new boolean[1];
119126
synchronized (this) {

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/patchresourcewithssa/PatchResourceWithSSAReconciler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public UpdateControl<PatchResourceWithSSACustomResource> reconcile(
4141
if (resource.getSpec().getControllerManagedValue() == null) {
4242
res.setSpec(new PatchResourceWithSSASpec());
4343
res.getSpec().setControllerManagedValue(ADDED_VALUE);
44-
return UpdateControl.patchResource(res);
44+
// test assumes we will run this in the next reconciliation
45+
return UpdateControl.patchResource(res).filterPatchEvent(false);
4546
} else {
4647
res.setStatus(new PatchResourceWithSSAStatus());
4748
res.getStatus().setSuccessfullyReconciled(true);

operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/patchresourcewithssa/PatchWithSSAITBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void reconcilerPatchesResourceWithSSA() {
4949
.isEqualTo(PatchResourceWithSSAReconciler.ADDED_VALUE);
5050
// finalizer is added to the SSA patch in the background by the framework
5151
assertThat(actualResource.getMetadata().getFinalizers()).isNotEmpty();
52+
assertThat(actualResource.getStatus()).isNotNull();
5253
assertThat(actualResource.getStatus().isSuccessfullyReconciled()).isTrue();
5354
// one for resource, one for subresource
5455
assertThat(

0 commit comments

Comments
 (0)