Skip to content

fix: issue with event source start ordering #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package io.javaoperatorsdk.operator.processing.event;

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;

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

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

@Override
public Set<EventSource> getRegisteredEventSources() {
return Collections.unmodifiableSet(eventSources);
return new HashSet<>(eventSources);
}

@Override
Expand Down