Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions internal/dag/executor/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func (e *docker) Run() error {
return err
}

defer func() {
if e.autoRemove {
err := cli.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{})
util.LogErr("docker executor: remove container", err)
}
}()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great refactoring of the clean-up function. Thank you!


statusCh, errCh := cli.ContainerWait(
ctx, resp.ID, container.WaitConditionNotRunning,
)
Expand All @@ -96,7 +103,10 @@ func (e *docker) Run() error {
if err != nil {
return err
}
case <-statusCh:
case status := <-statusCh:
if status.StatusCode != 0 {
return fmt.Errorf("exit status %v", status.StatusCode)
}
}

out, err := cli.ContainerLogs(
Expand All @@ -109,11 +119,6 @@ func (e *docker) Run() error {
_, err = stdcopy.StdCopy(e.stdout, e.stdout, out)
util.LogErr("docker executor: stdcopy", err)

if e.autoRemove {
err := cli.ContainerRemove(ctx, resp.ID, types.ContainerRemoveOptions{})
util.LogErr("docker executor: remove container", err)
}

return nil
}

Expand Down