chore(spawn-docker-jdk): drive PullImage off the /images/create progress stream - #62
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PullImagepreviously extendedAbstractEventBasedBlockingCommandand blocked by subscribing to the session-widePublisher<Event>, waiting for anActionEventwhose action waspulland whose id matched the requested image. This coupled a single image pull to the shared system-event stream, and if that event never arrived the command would either block indefinitely inprocessing.join()or report success regardless of what actually happened.PullImagenow extendsAbstractBlockingCommandand consumes the/images/createresponse body directly. The response is a stream of newline-delimited JSON progress objects that the Docker Engine holds open until the pull completes or fails;createResultreads that stream to exhaustion viaJsonNodeInputStreamProcessorand inspects each object. A terminalstatusvalue beginning withStatus:(covering bothStatus: Downloaded newer image for ...andStatus: Image is up to date for ...) marks success. An in-banderrorfield, which the Docker Engine reports while the HTTP status stays200, is captured and rethrown as anIOException. A stream that ends without either a terminal status or an error, such as a connection dropped mid-pull, is also treated as a failure. Observations are collected on a small single-threadedPullOutcomeholder sinceJsonNodeInputStreamProcessordelivers every object synchronously on the calling thread.AbstractEventBasedBlockingCommandhad no other subclasses and is deleted. One caller-visible consequence:Session.pull(...)now throws (aRuntimeExceptionwrapping theIOException, viaAbstractCommand.onRequestFailed) when a pull fails or its progress stream is truncated, instead of blocking or returning a value.