Skip to content

Commit

Permalink
fix: processor issue with cleanup resources (#2049)
Browse files Browse the repository at this point in the history
* fix: processor issue with cleanup resources

if leader election not running delete event was not cleaning up state

Signed-off-by: Attila Mészáros <[email protected]>

* revert small change

Signed-off-by: Attila Mészáros <[email protected]>

---------

Signed-off-by: Attila Mészáros <[email protected]>
  • Loading branch information
csviri authored Sep 8, 2023
1 parent 2aa8dfe commit ddd7c42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public synchronized void handleEvent(Event event) {
metrics.receivedEvent(event, metricsMetadata);
handleEventMarking(event, state);
if (!this.running) {
if (state.deleteEventPresent()) {
cleanupForDeletedEvent(state.getId());
}
// events are received and marked, but will be processed when started, see start() method.
log.debug("Skipping event: {} because the event processor is not started", event);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,21 @@ void executionOfReconciliationShouldNotStartIfProcessorStopped() throws Interrup
.handleExecution(any());
}

@Test
void cleansUpForDeleteEventEvenIfProcessorNotStarted() {
ResourceID resourceID = new ResourceID("test1", "default");

eventProcessor =
spy(new EventProcessor(controllerConfiguration(null, rateLimiterMock),
reconciliationDispatcherMock,
eventSourceManagerMock, null));

eventProcessor.handleEvent(prepareCREvent(resourceID));
eventProcessor.handleEvent(new ResourceEvent(ResourceAction.DELETED, resourceID, null));
eventProcessor.handleEvent(prepareCREvent(resourceID));
// no exception thrown
}

private ResourceID eventAlreadyUnderProcessing() {
when(reconciliationDispatcherMock.handleExecution(any()))
.then(
Expand Down

0 comments on commit ddd7c42

Please sign in to comment.