Make timeouts actually cancel the underlying processes #133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently,
PullImagesTimeout
,StartContainersTimeout
, andStopContainersTimeout
timeouts are enforced byAwait.ready
,Await.result
, ... e.g:docker-it-scala/core/src/main/scala/com/whisk/docker/DockerKit.scala
Lines 57 to 60 in 4d3bc7e
When the timeout expires, however, the
Future
'sbody
code keeps running even if theTimeoutException
has been raised. As an example, run this code in a Scala REPL:The result is that the exception is raised and yet "BOOM" is printed:
This means that, as we try to stop the containers in
afterAll
:docker-it-scala/scalatest/src/main/scala/com/whisk/docker/scalatest/DockerTestKit.scala
Lines 24 to 28 in 4d3bc7e
We might still be trying to start them in a separate thread.
This PR introduces
timeout
parameters inDockerCommandExecutor
methods which propagates down to the implementations of this interface. There, it replacesFuture.apply
factory invocation withPerishableFuture.apply
. It also addsPerishableFuture
factory which makes sure thebody
gets interrupted when the timeout expires:If the passed timeout is
Duration.Inf
it just doesn't timeout so it uses standardFuture
factory:These changes should improve host resources usage and pave the way to more advanced timeouts customization.