Skip to content

Commit f78d143

Browse files
committed
Correct logic
1 parent 4de9343 commit f78d143

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

operator/src/main/java/oracle/kubernetes/operator/Watcher.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,16 @@ protected boolean isStopping() {
122122

123123
private void watchForEvents() {
124124
long now = System.currentTimeMillis();
125-
long delta = now - lastInitialize;
126-
if (lastInitialize != 0 && delta > (tuning.watchMinimumDelay * 1000)) {
125+
long delay = (tuning.watchMinimumDelay * 1000) - (now - lastInitialize);
126+
if (lastInitialize != 0 && delay > 0) {
127127
try {
128-
Thread.sleep(delta);
128+
Thread.sleep(delay);
129129
} catch (InterruptedException ex) {
130130
LOGGER.warning(MessageKeys.EXCEPTION, ex);
131131
}
132132
lastInitialize = System.currentTimeMillis();
133+
} else {
134+
lastInitialize = now;
133135
}
134136
try (WatchI<T> watch =
135137
initiateWatch(

operator/src/test/java/oracle/kubernetes/operator/WatcherTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public abstract class WatcherTestBase extends ThreadFactoryTestBase
4141

4242
private int resourceVersion = INITIAL_RESOURCE_VERSION;
4343

44-
protected WatchTuning tuning = new WatchTuning(30, 5);
44+
protected WatchTuning tuning = new WatchTuning(30, 0);
4545

4646
private V1ObjectMeta createMetaData() {
4747
return createMetaData("test", NAMESPACE);

operator/src/test/java/oracle/kubernetes/operator/helpers/DomainIntrospectorJobTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static String getJobName() {
290290
}
291291

292292
FiberTestSupport.StepFactory getStepFactory() {
293-
return next -> JobHelper.createDomainIntrospectorJobStep(new WatchTuning(30, 5), next);
293+
return next -> JobHelper.createDomainIntrospectorJobStep(new WatchTuning(30, 0), next);
294294
}
295295

296296
V1PodList createListPods() {

0 commit comments

Comments
 (0)