Skip to content

Commit 73f3c13

Browse files
committed
fixes
1 parent 5e71ede commit 73f3c13

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/informer/InformerConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public <P extends HasMetadata> InformerConfigurationBuilder<R> withNamespacesInh
164164
}
165165

166166
/**
167-
* Whether or not the associated informer should track changes made to the parent
167+
* Whether the associated informer should track changes made to the parent
168168
* {@link io.javaoperatorsdk.operator.processing.Controller}'s namespaces configuration.
169169
*
170170
* @param followChanges {@code true} to reconfigure the associated informer when the parent

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.javaoperatorsdk.operator.processing.Controller;
1818
import io.javaoperatorsdk.operator.processing.LifecycleAware;
1919
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
20+
import io.javaoperatorsdk.operator.processing.event.source.EventSourceStartPriority;
2021
import io.javaoperatorsdk.operator.processing.event.source.ResourceEventAware;
2122
import io.javaoperatorsdk.operator.processing.event.source.ResourceEventSource;
2223
import io.javaoperatorsdk.operator.processing.event.source.controller.ControllerResourceEventSource;
@@ -63,7 +64,12 @@ public void postProcessDefaultEventSourcesAfterProcessorInitializer() {
6364
@Override
6465
public synchronized void start() {
6566
startEventSource(eventSources.namedControllerResourceEventSource());
66-
eventSources.additionalNamedEventSources().parallel().forEach(this::startEventSource);
67+
eventSources.additionalNamedEventSources()
68+
.filter(es -> es.priority().equals(EventSourceStartPriority.RESOURCE_STATE_LOADER))
69+
.parallel().forEach(this::startEventSource);
70+
eventSources.additionalNamedEventSources()
71+
.filter(es -> es.priority().equals(EventSourceStartPriority.DEFAULT))
72+
.parallel().forEach(this::startEventSource);
6773
}
6874

6975
@Override

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import io.javaoperatorsdk.operator.OperatorException;
66
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
7+
import io.javaoperatorsdk.operator.processing.event.source.EventSourceStartPriority;
78

89
class NamedEventSource implements EventSource {
910

@@ -57,4 +58,9 @@ public boolean equals(Object o) {
5758
public int hashCode() {
5859
return Objects.hash(original, name);
5960
}
61+
62+
@Override
63+
public EventSourceStartPriority priority() {
64+
return original.priority();
65+
}
6066
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public abstract class AbstractEventSource implements EventSource {
77
private EventHandler handler;
88
private volatile boolean running = false;
9-
private EventSourceStartPriority eventSourceStartPriority;
9+
private EventSourceStartPriority eventSourceStartPriority = EventSourceStartPriority.DEFAULT;
1010

1111
protected EventHandler getEventHandler() {
1212
return handler;

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventSourceManagerTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
1313
import io.javaoperatorsdk.operator.processing.Controller;
1414
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
15+
import io.javaoperatorsdk.operator.processing.event.source.EventSourceStartPriority;
1516
import io.javaoperatorsdk.operator.processing.event.source.controller.ControllerResourceEventSource;
1617
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;
1718
import io.javaoperatorsdk.operator.processing.event.source.informer.ManagedInformerEventSource;
@@ -59,7 +60,9 @@ public void closeShouldCascadeToEventSources() {
5960
@Test
6061
public void startCascadesToEventSources() {
6162
EventSource eventSource = mock(EventSource.class);
63+
when(eventSource.priority()).thenReturn(EventSourceStartPriority.DEFAULT);
6264
EventSource eventSource2 = mock(TimerEventSource.class);
65+
when(eventSource2.priority()).thenReturn(EventSourceStartPriority.DEFAULT);
6366
eventSourceManager.registerEventSource(eventSource);
6467
eventSourceManager.registerEventSource(eventSource2);
6568

operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/externalstate/ExternalStateReconciler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private void createExternalResource(ExternalStateCustomResource resource) {
5858
.build())
5959
.withData(Map.of(ID_KEY, createdResource.getId()))
6060
.build();
61+
configMap.addOwnerReference(resource);
6162
client.configMaps().resource(configMap).create();
6263

6364
var primaryID = ResourceID.fromResource(resource);

0 commit comments

Comments
 (0)