Skip to content

Commit d3d7193

Browse files
committed
Async issues in Fiber and Watcher
1 parent 18aaf36 commit d3d7193

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private void watchForEvents() {
143143
new WatchBuilder()
144144
.withResourceVersion(resourceVersion.toString())
145145
.withTimeoutSeconds(tuning.watchLifetime))) {
146-
while (watch.hasNext()) {
146+
while (hasNext(watch)) {
147147
Watch.Response<T> item = watch.next();
148148

149149
if (isStopping()) {
@@ -164,6 +164,15 @@ private void watchForEvents() {
164164
}
165165
}
166166

167+
private boolean hasNext(WatchI<T> watch) {
168+
try {
169+
return watch.hasNext();
170+
} catch (Throwable ex) {
171+
// no-op on exception during hasNext
172+
}
173+
return false;
174+
}
175+
167176
/**
168177
* Initiates a watch by using the watch builder to request any updates for the specified watcher.
169178
*

operator/src/main/java/oracle/kubernetes/operator/calls/AsyncRequestStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void onSuccess(
190190
try {
191191
cc.cancel();
192192
} finally {
193-
LOGGER.info(
193+
LOGGER.fine(
194194
MessageKeys.ASYNC_TIMEOUT,
195195
requestParams.call,
196196
requestParams.namespace,

operator/src/main/java/oracle/kubernetes/operator/work/Fiber.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ public void start(Step stepline, Packet packet, CompletionCallback completionCal
148148
this.na.invoke(stepline, packet);
149149
this.completionCallback = completionCallback;
150150

151-
if (LOGGER.isFineEnabled()) {
152-
breadCrumbs = new ArrayList<>();
153-
LOGGER.fine("{0} started", new Object[] {getName()});
154-
}
155-
156151
if (status.get() == NOT_COMPLETE) {
152+
if (LOGGER.isFineEnabled()) {
153+
breadCrumbs = new ArrayList<>();
154+
LOGGER.fine("{0} started", new Object[] {getName()});
155+
}
156+
157157
owner.addRunnable(this);
158158
}
159159
}
@@ -262,7 +262,12 @@ public Fiber createChildFiber() {
262262
children = new ArrayList<>();
263263
}
264264
children.add(child);
265-
addBreadCrumb(child);
265+
if (status.get() == NOT_COMPLETE) {
266+
addBreadCrumb(child);
267+
} else {
268+
// Race condition where child is created after parent is cancelled or done
269+
child.status.set(CANCELLED);
270+
}
266271
}
267272

268273
return child;

0 commit comments

Comments
 (0)