You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
The LogStream::readFully() associated with a detached exec seems to return an empty String.
Background: We would like to run a detached program that may take a while to finish, and so we would like to abort waiting for it under certain circumstances (we're shutting down, or a timeout has been reached). So we have code similar to what's shown below. Unfortunately, stream.readFully() unexpectedly returns an empty String when !running, which is strange because if we use a non-detached version, we can confirm the output is non-empty as it should be.
Our hypothesis is that stream.readFully() returns an empty String, always, on a detached exec instance. Is this true? As mentioned above, we would like to be able to terminate the waiting of the completion of the command, how can this be accomplished? The API suggests it may be possible to interrupt the thread, however we would strongly prefer to avoid interrupting threads (for many reasons).
String execId = docker.execCreate(name, args,
DockerClient.ExecCreateParam.attachStdout(),
DockerClient.ExecCreateParam.attachStderr());
try (LogStream streamTmp = docker.execStart(execId, DockerClient.ExecStartParameter.DETACH)) {
long startNanoTime = System.nanoTime();
long sleepMillis = 10;
while (!condition.shouldAbort()) {
try {
ExecState state = docker.execInspect(execId);
if (!state.running()) {
return new ProcessResult(state.exitCode(), stream.readFully());
}
if (System.nanoTime() - startNanoTime > timeout.toNanos()) {
// TODO: Would be great if we could attach stdout/stderr
// ... unfortunately LogStream.readFully() blocks.
throw new TimeoutException("Command " + args + " for container " + containerName
+ " timed out after " + timeout.toMillis() + " ms");
}
sleepMillis = Math.min(2 * sleepMillis, 1_000);
try { Thread.sleep(sleepMillis); } catch (InterruptedException e) { }
}
}
How to reproduce
See above
What do you expect
I would have expected the LogStream to be connected to the stdout/stderr as defined by our DockerClient.ExecCreateParam to execCreate(), and LogStream::readFully() after the program has completed should return the full stdout/stderr (depending on the DockerClient.ExecCreateParam).
What happened instead
An empty string is returned.
Software:
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5
Built: Fri Nov 20 13:29:22 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5
Built: Fri Nov 20 13:29:22 UTC 2015
OS/Arch: linux/amd64
docker version: [Add docker version here, client and server]
docker-client version: 3.5.12
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Description
The LogStream::readFully() associated with a detached exec seems to return an empty String.
Background: We would like to run a detached program that may take a while to finish, and so we would like to abort waiting for it under certain circumstances (we're shutting down, or a timeout has been reached). So we have code similar to what's shown below. Unfortunately, stream.readFully() unexpectedly returns an empty String when !running, which is strange because if we use a non-detached version, we can confirm the output is non-empty as it should be.
Our hypothesis is that stream.readFully() returns an empty String, always, on a detached exec instance. Is this true? As mentioned above, we would like to be able to terminate the waiting of the completion of the command, how can this be accomplished? The API suggests it may be possible to interrupt the thread, however we would strongly prefer to avoid interrupting threads (for many reasons).
How to reproduce
See above
What do you expect
I would have expected the LogStream to be connected to the stdout/stderr as defined by our DockerClient.ExecCreateParam to execCreate(), and LogStream::readFully() after the program has completed should return the full stdout/stderr (depending on the DockerClient.ExecCreateParam).
What happened instead
An empty string is returned.
Software:
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5
Built: Fri Nov 20 13:29:22 UTC 2015
OS/Arch: linux/amd64
Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5
Built: Fri Nov 20 13:29:22 UTC 2015
OS/Arch: linux/amd64
The text was updated successfully, but these errors were encountered: