Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passes 'docker load' error back to user. #334

Merged
merged 6 commits into from
Jun 1, 2018
Merged

Conversation

coollog
Copy link
Contributor

@coollog coollog commented May 31, 2018

Fixes #330

This exposes the docker load error to the user so that they can take action to fix it.

@chanseokoh

@coollog coollog requested review from TadCordle and loosebazooka May 31, 2018 16:40
// This error usually happens when docker is not able to connect to the daemon socket.
try (InputStreamReader stderr =
new InputStreamReader(dockerProcess.getErrorStream(), StandardCharsets.UTF_8)) {
String error = CharStreams.toString(stderr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can 87-89 throw an IOException? If so, we might want to be careful about passing that through to the caller of load

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this assumes IOException will be errors at the docker application level only (i.e., the docker process knows what the issue was and prints it to stderr). Technically speaking, writing to a process stdin may fail for reasons other than application level failures. For example, the docker process crashing for some unknown reason, docker command-not-found, no executable-bit set on the docker command binary, etc., and in such cases, dockerProcess.getErrorStream() may have nothing but the original IOException would better describe the situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reorganized the code a bit and passed the original IOException as a cause to the custom generated IOException so that it wouldn't be left discarded.

try (OutputStream stdin = dockerProcess.getOutputStream()) {
imageTarballBlob.writeTo(stdin);
}
writeToStdin(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new method feels like it adds a high cost to readability/code complexity without enough benefit. It feels like we're decoupling the exception handling and method calls in an unnatural way. I would prefer if we kept this simple here (was this for testing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I moved everything back to load.

@coollog coollog merged commit dea7eda into master Jun 1, 2018
@coollog coollog deleted the give-docker-error branch June 1, 2018 16:52
@GoogleContainerTools GoogleContainerTools deleted a comment from coollog Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message from jib:buildDocker when docker command requires sudo
3 participants