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

Don't wait for container to stop if the client disconnects. #589

Merged
merged 2 commits into from
Jul 16, 2015
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

* Implemented support for attached one-off commands #568

**Bugs**

* Fixes a bug that caused containers launched by one-off tasks to stay around if the client disconnected. #589

## 0.9.0 (2015-06-16)

Initial public release
23 changes: 1 addition & 22 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,11 @@ func (r *Runner) Run(ctx context.Context, opts RunOpts) error {
if err := r.start(ctx, c.ID); err != nil {
return fmt.Errorf("runner: start containeer: %v", err)
}
defer tryClose(opts.Output)

if err := r.attach(ctx, c.ID, opts.Input, opts.Output); err != nil {
return fmt.Errorf("runner: attach: %v", err)
}
defer tryClose(opts.Output)

if err := r.wait(c.ID); err != nil {
return fmt.Errorf("runner: wait: %v", err)
}

if err := r.stop(ctx, c.ID); err != nil {
if _, ok := err.(*docker.ContainerNotRunning); ok {
return nil
}

return fmt.Errorf("runner: stop: %v", err)
}

return nil
}
Expand Down Expand Up @@ -131,15 +119,6 @@ func (r *Runner) attach(ctx context.Context, id string, in io.Reader, out io.Wri
})
}

func (r *Runner) wait(id string) error {
_, err := r.client.WaitContainer(id)
return err
}

func (r *Runner) stop(ctx context.Context, id string) error {
return r.client.StopContainer(ctx, id, DefaultStopTimeout)
}

func (r *Runner) remove(ctx context.Context, id string) error {
return r.client.RemoveContainer(ctx, docker.RemoveContainerOptions{
ID: id,
Expand Down