Skip to content

Commit 1e6a90e

Browse files
committed
revert: fix: if a stop handler is set, use it by default
This reverts commit 7d007db.
1 parent 9574a03 commit 1e6a90e

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,9 @@ default Optional<LeaderElectionConfiguration> getLeaderElectionConfiguration() {
164164
* if false, the startup will ignore recoverable errors, caused for example by RBAC issues, and
165165
* will try to reconnect periodically in the background.
166166
* </p>
167-
* <p>
168-
* NOTE: this setting is ignored if an informer stop handler is set
169-
* </p>
170167
*/
171168
default boolean stopOnInformerErrorDuringStartup() {
172-
return getInformerStoppedHandler().isEmpty();
169+
return true;
173170
}
174171

175172
/**

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ public Optional<InformerStoppedHandler> getInformerStoppedHandler() {
188188

189189
@Override
190190
public boolean stopOnInformerErrorDuringStartup() {
191-
// only stop on informer error if we didn't set a stop handler for the informers
192-
return stopOnInformerErrorDuringStartup != null && informerStoppedHandler == null
193-
? stopOnInformerErrorDuringStartup
191+
return stopOnInformerErrorDuringStartup != null ? stopOnInformerErrorDuringStartup
194192
: super.stopOnInformerErrorDuringStartup();
195193
}
196194

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerEventSourceTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.fabric8.kubernetes.api.model.apps.Deployment;
1111
import io.fabric8.kubernetes.client.KubernetesClient;
1212
import io.javaoperatorsdk.operator.MockKubernetesClient;
13+
import io.javaoperatorsdk.operator.OperatorException;
1314
import io.javaoperatorsdk.operator.api.config.ConfigurationServiceProvider;
1415
import io.javaoperatorsdk.operator.api.config.InformerStoppedHandler;
1516
import io.javaoperatorsdk.operator.api.config.informer.InformerConfiguration;
@@ -19,6 +20,7 @@
1920
import io.javaoperatorsdk.operator.sample.simple.TestCustomResource;
2021

2122
import static io.javaoperatorsdk.operator.api.reconciler.Constants.DEFAULT_NAMESPACES_SET;
23+
import static org.junit.jupiter.api.Assertions.assertThrows;
2224
import static org.mockito.ArgumentMatchers.any;
2325
import static org.mockito.ArgumentMatchers.eq;
2426
import static org.mockito.Mockito.atLeastOnce;
@@ -258,7 +260,7 @@ void informerStoppedHandlerShouldBeCalledWhenInformerStops() {
258260

259261
// by default informer fails to start if there is an exception in the client on start.
260262
// Throws the exception further.
261-
informerEventSource.start();
263+
assertThrows(OperatorException.class, () -> informerEventSource.start());
262264
verify(informerStoppedHandler, atLeastOnce()).onStop(any(), eq(exception));
263265
} finally {
264266
ConfigurationServiceProvider.reset();

0 commit comments

Comments
 (0)