Conversation
c62d51c to
ccfcdaf
Compare
builder/docker/builder.go
Outdated
| waiter, err := client.AttachToContainerNonBlocking(attachOptions) | ||
| if err != nil { | ||
| return err | ||
| return "", err |
There was a problem hiding this comment.
We should return cont.ID both here and after a StartContainer error to allow the container to be removed even after a failure. Another possibility is removing the container inside this function if we are to return an error.
builder/docker/builder.go
Outdated
|
|
||
| return map[string]interface{}{ | ||
| "healthcheck": yaml.Healthcheck, | ||
| "hooks": map[string]interface{}{ |
There was a problem hiding this comment.
I think having "hooks": yaml.Hooks, would work here.
| cmd := fmt.Sprintf("(cat %s/tsuru.yml || cat %s/tsuru.yaml || cat %s/app.yml || cat %s/app.yaml || true) 2>/dev/null", path, path, path, path) | ||
| var buf bytes.Buffer | ||
| err := runCommandInContainer(client, evt, imageID, cmd, app, &buf, nil) | ||
| containerID, err := runCommandInContainer(client, evt, imageID, cmd, app, &buf, nil) |
There was a problem hiding this comment.
What do you think about moving the defer RemoveContainer(containerID) call to this function instead of returning the ID and making the parent remove it?
There was a problem hiding this comment.
The problem is that I call runCommandInContainer also in runBuildHooks function, and I can't remove it there, because it's commited
There was a problem hiding this comment.
Oh right, you can only remove it after it's been pushed. 👍
| repo, tag := splitImageName(imageID) | ||
| opts := docker.CommitContainerOptions{ | ||
| Container: containerID, | ||
| Repository: repo, |
There was a problem hiding this comment.
I think the only reason why Repository and Tag is needed here is because of a bug in docker-cluster, as it isn't storing information about the image if they are not present. Let's leave it like this for now but we may be able to simplify this in the future.
|
@cezarsa PTAL |
7320cd1 to
266ffed
Compare
| fmt.Fprintf(evt, " ---> Running %q\n", cmd) | ||
| containerID, err := runCommandInContainer(client, evt, imageID, cmd, app, evt, evt) | ||
| if err != nil { | ||
| return "", err |
There was a problem hiding this comment.
Return containerID here to ensure removal in case of partial failure.
Set deploy hooks when deploying from an image