Skip to content

Commit

Permalink
fix fabric8io#4910 fabric8io#4923: addressing vertx and general race …
Browse files Browse the repository at this point in the history
…condition with exec
  • Loading branch information
shawkins committed Mar 9, 2023
1 parent f64529c commit 42d0253
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Fix #4931: using coarse grain locking for all mock server operations
* Fix #4947: typo in HttpClient.Factory scoring system logic
* Fix #4928: allows non-okhttp clients to handle invalid status
* Fix #4910 / #4923: addressing inconsistent behavior with pod exec operations

#### Improvements
* Fix #4675: adding a fully client side timeout for informer watches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ void init() {
ws.pause();
listener.onMessage(this, msg);
});
ws.closeHandler(v -> listener.onClose(this, ws.closeStatusCode(), ws.closeReason()));
// if the server sends a ping, we're in trouble with our fetch strategy as there is
// no ping handler to increase the demand - this should not be an immediate issue as
// the api server does not seem to be sending pings

// if for whatever reason we send a ping, pong counts against the demand, so we need more
ws.pongHandler(b -> ws.fetch(1));
// use end, not close, because close is processed immediately vs. end is in frame order
ws.endHandler(v -> listener.onClose(this, ws.closeStatusCode(), ws.closeReason()));
ws.exceptionHandler(err -> listener.onError(this, err));
listener.onOpen(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void consume(List<ByteBuffer> value) {
request.run();
return;
}
assert !complete || failed == null;
buffers.addAll(value);
buffers.notifyAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,16 @@ private InputStream read(String... command) {
private Future<?> readTo(OutputStream out, String... cmd) {
ExecWatch w = writingOutput(out).exec(cmd);
CompletableFuture<Integer> result = w.exitCode();
result.whenComplete((i, t) -> {
// ensure the whenComplete runs prior to downstream actions
return result.whenComplete((i, t) -> {
try {
out.close();
} catch (Exception e) {
result.obtrudeException(e);
} finally {
w.close();
}
w.close();
});
return result;
}

private void copyDir(String source, File target) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void copyDir() throws IOException {
PodResource podResource = client.pods().withName("pod-standard");
podResource.dir("/etc").withReadyWaitTimeout(POD_READY_WAIT_IN_MILLIS).copy(tmpDir);

Path msg = tmpDir.resolve("/etc/hosts");
Path msg = tmpDir.resolve("etc/hosts");
assertTrue(Files.exists(msg));
}

Expand Down

0 comments on commit 42d0253

Please sign in to comment.