Conversation
|
is the pull step before this? lazy and didn't see it in the diff (sorry). users shouldn't need to manually pull the init image and docker inspect will burp if the image isn't downloaded locally (which was the point I think? got that) -- docker build itself will pull the image, i'm assuming we were just relying on that, which makes sense to me. |
|
I changed this to simply handle |
|
I think that all cases are properly handled (init-image not found, docker down, docker not in path, untar failing). I couldn't make error handling fails. |
| _, errStdout = io.Copy(stdout, stdoutIn) | ||
| _, errStderr = io.Copy(stderr, stderrIn) | ||
|
|
||
| errUntar := untarStream(bytes.NewReader(stdoutBuf.Bytes())) |
There was a problem hiding this comment.
sorry for delay here. we can use the io.Pipe and not need to buffer here - this is a good idea because images are on the order of megabytes. we don't actually use stderr it seems so i'm thinking something like:
tarIn, tarOut := io.Pipe()
cmd := exec.Command("...")
cmd.Stderr = ioutil.Discard // honestly, os.Stderr makes sense, we can do w/e
cmd.Stdout = tarOut
err := cmd.Start()
if err != nil {
return err
}
err = untarStream(tarIn)
if err != nil {
return err // can format error about init image here, add stderr if we want
}
err = cmd.Wait()
if err != nil {
return err // can format error about init image here, add stderr if we want
}this pretty much expects that untar stream will fuck up if the command fucks up. if for some reason it doesn't, then we can get the exit code out of Wait(). in the happy path we expect untar to just work, and Wait() to return a nil error. I think that this makes sense, but double check me :) wdyt?
Simple fix that uses
docker inspectto check that Docker is running and that the init-image exists.