@@ -64,13 +64,19 @@ void scheduleEventFromApi(CustomResourceEvent event) {
6464 try {
6565 lock .lock ();
6666 log .debug ("Scheduling event from Api: {}" , event );
67- if (event .getResource ().getMetadata ().getDeletionTimestamp () != null && event .getAction () == Action .DELETED ) {
68- // Note that we always use finalizers, we want to process delete event just in corner case,
69- // when we are not able to add finalizer (lets say because of optimistic locking error, and the resource was deleted instantly).
70- // We want to skip in case of finalizer was there since we don't want to execute delete method always at least 2x,
71- // which would be the result if we don't skip here. (there is no deletion timestamp if resource deleted without finalizer.)
72- log .debug ("Skipping delete event since deletion timestamp is present on resource, so finalizer was in place." );
73- return ;
67+ if (event .getAction () == Action .DELETED ) {
68+ // This removes data from memory for deleted resource (prevent memory leak basically).
69+ // Its quite interesting that this is always sufficient here (no finalizer or other mechanism needs to be involved).
70+ // Thus, if operator is running we get DELETE the event, if not the memory is already gone anyways.
71+ eventStore .removeLastGenerationForDeletedResource (event .resourceUid ());
72+ if (event .getResource ().getMetadata ().getDeletionTimestamp () != null ) {
73+ // Note that we always use finalizers, we want to process delete event just in corner case,
74+ // when we are not able to add finalizer (lets say because of optimistic locking error, and the resource was deleted instantly).
75+ // We want to skip in case of finalizer was there since we don't want to execute delete method always at least 2x,
76+ // which would be the result if we don't skip here. (there is no deletion timestamp if resource deleted without finalizer.)
77+ log .debug ("Skipping delete event since deletion timestamp is present on resource, so finalizer was in place." );
78+ return ;
79+ }
7480 }
7581 // In case of generation aware processing, we want to replace this even if generation not increased,
7682 // to have the most recent copy of the event.
0 commit comments