Skip to content

Commit 46d8fde

Browse files
committed
docs improvements
1 parent 9f7bebb commit 46d8fde

File tree

1 file changed

+10
-8
lines changed
  • operator-framework/src/main/java/com/github/containersolutions/operator/processing

1 file changed

+10
-8
lines changed

operator-framework/src/main/java/com/github/containersolutions/operator/processing/EventScheduler.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@
3434
* </li>
3535
* <li>Threading approach thus thread pool size and/or implementation should be configurable</li>
3636
* </ul>
37+
* <p>
38+
* Notes:
39+
* <ul>
40+
* <li> In implementation we have to lock since the fabric8 client event handling is multi-threaded, we can receive multiple events
41+
* for same resource. Also we do callback from other threads.
42+
* </li>
43+
* <li>We don't react for delete event, since we always use finalizers and do delete on marked for deletion.</li>
44+
* </ul>
3745
*
3846
* @param <R>
3947
*/
4048

41-
/**
42-
*
43-
**/
4449
public class EventScheduler<R extends CustomResource> implements Watcher<R> {
4550

4651
private final static Logger log = LoggerFactory.getLogger(EventScheduler.class);
@@ -73,8 +78,6 @@ void scheduleEvent(CustomResourceEvent newEvent) {
7378
log.debug("Current queue size {}", executor.getQueue().size());
7479
log.info("Scheduling event: {}", newEvent.getEventInfo());
7580
try {
76-
// we have to lock since the fabric8 client event handling is multi-threaded,
77-
// so in the following part could be a race condition when multiple events are received for same resource.
7881
lock.lock();
7982
if (eventStore.processedNewerVersionBefore(newEvent)) {
8083
log.debug("Skipping event processing since was processed event with newer version before. {}", newEvent);
@@ -83,7 +86,6 @@ void scheduleEvent(CustomResourceEvent newEvent) {
8386
if (newEvent.getAction() == Action.DELETED) {
8487
return;
8588
}
86-
// if there is an event waiting for to be scheduled we just replace that.
8789
if (eventStore.containsOlderVersionOfNotScheduledEvent(newEvent)) {
8890
log.debug("Replacing event which is not scheduled yet, since incoming event is more recent. new Event:{}", newEvent);
8991
eventStore.addOrReplaceEventAsNotScheduledYet(newEvent);
@@ -130,8 +132,8 @@ boolean eventProcessingStarted(CustomResourceEvent event) {
130132
lock.lock();
131133
EventStore.ResourceScheduleHolder res = eventStore.removeEventScheduledForProcessing(event.resourceUid());
132134
if (res == null) {
133-
// if its still scheduled for processing.
134-
// note that it can happen that we scheduled an event for processing, it took some time that is was picked
135+
// Double checking if the event is still scheduled. This is a corner case, but can actually happen.
136+
// In detail: it can happen that we scheduled an event for processing, it took some time that is was picked
135137
// by executor, and it was removed during that time from the schedule but not cancelled yet. So to be correct
136138
// this should be checked also here. In other word scheduleEvent function can run in parallel with eventDispatcher.
137139
return false;

0 commit comments

Comments
 (0)