Skip to content

Commit cc340ba

Browse files
committed
fixes from CR
1 parent 1e30905 commit cc340ba

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3+
import java.time.Duration;
34
import java.util.Optional;
45
import java.util.Set;
56
import java.util.concurrent.ExecutorService;
@@ -170,8 +171,8 @@ default boolean stopOnInformerErrorDuringStartup() {
170171
* "stopOnInformerErrorDuringStartup" is true the operator will stop on timeout. Default is 2
171172
* minutes.
172173
*/
173-
default int cacheSyncTimeout() {
174-
return 2 * 60 * 1000;
174+
default Duration cacheSyncTimeout() {
175+
return Duration.ofMinutes(2);
175176
}
176177

177178
/**

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3+
import java.time.Duration;
34
import java.util.Optional;
45
import java.util.Set;
56
import java.util.concurrent.ExecutorService;
@@ -28,7 +29,7 @@ public class ConfigurationServiceOverrider {
2829
private LeaderElectionConfiguration leaderElectionConfiguration;
2930
private InformerStoppedHandler informerStoppedHandler;
3031
private Boolean stopOnInformerErrorDuringStartup;
31-
private Integer cacheSyncTimeout;
32+
private Duration cacheSyncTimeout;
3233

3334
ConfigurationServiceOverrider(ConfigurationService original) {
3435
this.original = original;
@@ -107,7 +108,7 @@ public ConfigurationServiceOverrider withStopOnInformerErrorDuringStartup(
107108
return this;
108109
}
109110

110-
public ConfigurationServiceOverrider withCacheSyncTimeout(int cacheSyncTimeout) {
111+
public ConfigurationServiceOverrider withCacheSyncTimeout(Duration cacheSyncTimeout) {
111112
this.cacheSyncTimeout = cacheSyncTimeout;
112113
return this;
113114
}
@@ -192,7 +193,7 @@ public boolean stopOnInformerErrorDuringStartup() {
192193
}
193194

194195
@Override
195-
public int cacheSyncTimeout() {
196+
public Duration cacheSyncTimeout() {
196197
return cacheSyncTimeout != null ? cacheSyncTimeout : super.cacheSyncTimeout();
197198
}
198199
};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public void start() throws OperatorException {
6969
// note that in case we don't put here timeout and stopOnInformerErrorDuringStartup is
7070
// false, and there is a rbac issue the get never returns; therefore operator never really
7171
// starts
72-
start.toCompletableFuture().get(configService.cacheSyncTimeout(), TimeUnit.MILLISECONDS);
72+
start.toCompletableFuture().get(configService.cacheSyncTimeout().toMillis(),
73+
TimeUnit.MILLISECONDS);
7374
} catch (TimeoutException | ExecutionException e) {
7475
log.warn("Informer startup error. Informer: {}", informer, e);
7576
if (configService.stopOnInformerErrorDuringStartup()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Operator startOperator(boolean stopOnInformerErrorDuringStartup) {
189189
Operator operator = new Operator(clientUsingServiceAccount(),
190190
co -> {
191191
co.withStopOnInformerErrorDuringStartup(stopOnInformerErrorDuringStartup);
192-
co.withCacheSyncTimeout(3000);
192+
co.withCacheSyncTimeout(Duration.ofMillis(3000));
193193
co.withInformerStoppedHandler((informer, ex) -> {
194194
stopHandlerCalled = true;
195195
});

0 commit comments

Comments
 (0)