Skip to content

Commit 508fec1

Browse files
committed
wip
1 parent 3dae636 commit 508fec1

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Operator implements LifecycleAware {
3232
private final LeaderElectionManager leaderElectionManager =
3333
new LeaderElectionManager(controllerManager);
3434
private volatile boolean started = false;
35+
private volatile boolean clientClosed = false;
3536

3637
public Operator() {
3738
this((KubernetesClient) null);
@@ -137,6 +138,7 @@ public void stop() throws OperatorException {
137138
if (configurationService.closeClientOnStop()) {
138139
kubernetesClient.close();
139140
}
141+
140142
started = false;
141143
}
142144

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ public void start() throws OperatorException {
6262
}
6363

6464
private void initSources() {
65-
sources.clear();
65+
if (!sources.isEmpty()) {
66+
throw new IllegalStateException("Some sources already initialized.");
67+
}
6668
cloner = ConfigurationServiceProvider.instance().getResourceCloner();
67-
6869
final var targetNamespaces = configuration.getEffectiveNamespaces();
6970
if (ResourceConfiguration.allNamespacesWatched(targetNamespaces)) {
7071
var source = createEventSourceForNamespace(WATCH_ALL_NAMESPACES);
@@ -136,6 +137,7 @@ public void stop() {
136137
log.warn("Error stopping informer for namespace: {} -> {}", ns, source, e);
137138
}
138139
});
140+
sources.clear();
139141
}
140142

141143
@Override

operator-framework/src/test/java/io/javaoperatorsdk/operator/OperatorRestartIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ void operatorCanBeRestarted() {
1919
try (var client = new KubernetesClientBuilder().build()) {
2020
LocallyRunOperatorExtension.applyCrd(RestartTestCustomResource.class,
2121
client);
22-
Operator operator = new Operator();
22+
// todo check if this is good enough for Quarkus dev mode
23+
Operator operator = new Operator(o->o.withCloseClientOnStop(false));
2324
var reconciler = new RestartTestReconciler();
2425
operator.register(reconciler);
2526
operator.start();

0 commit comments

Comments
 (0)