Skip to content

Commit 3f68140

Browse files
authored
fix: issue with event source start ordering (#736)
1 parent 9b9de3e commit 3f68140

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.javaoperatorsdk.operator.processing.event;
22

3-
import java.util.Collections;
4-
import java.util.HashSet;
5-
import java.util.Objects;
6-
import java.util.Set;
3+
import java.util.*;
74
import java.util.concurrent.locks.ReentrantLock;
85

96
import org.slf4j.Logger;
@@ -25,7 +22,10 @@ public class EventSourceManager<R extends HasMetadata>
2522
private static final Logger log = LoggerFactory.getLogger(EventSourceManager.class);
2623

2724
private final ReentrantLock lock = new ReentrantLock();
28-
private final Set<EventSource> eventSources = Collections.synchronizedSet(new HashSet<>());
25+
// This needs to be a list since the event source must be started in a deterministic order. The
26+
// controllerResourceEventSource must be always the first to have informers available for other
27+
// informers to access the main controller cache.
28+
private final List<EventSource> eventSources = Collections.synchronizedList(new ArrayList<>());
2929
private final EventProcessor<R> eventProcessor;
3030
private TimerEventSource<R> retryAndRescheduleTimerEventSource;
3131
private ControllerResourceEventSource<R> controllerResourceEventSource;
@@ -120,7 +120,7 @@ public void cleanupForCustomResource(ResourceID customResourceUid) {
120120

121121
@Override
122122
public Set<EventSource> getRegisteredEventSources() {
123-
return Collections.unmodifiableSet(eventSources);
123+
return new HashSet<>(eventSources);
124124
}
125125

126126
@Override

0 commit comments

Comments
 (0)