diff options
author | Brent Baude <bbaude@redhat.com> | 2020-05-20 12:49:55 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-05-20 13:02:18 -0500 |
commit | ce24e1139c63b35ddc2c6b176e5701de1dc9f8b5 (patch) | |
tree | 4e14cca7c4f9c795bdd83008b66d0bf1680c37e2 /pkg/domain/infra | |
parent | 09f8f14b4f7d09946d3d5cfc5460ec9923f7da59 (diff) | |
download | podman-ce24e1139c63b35ddc2c6b176e5701de1dc9f8b5.tar.gz podman-ce24e1139c63b35ddc2c6b176e5701de1dc9f8b5.tar.bz2 podman-ce24e1139c63b35ddc2c6b176e5701de1dc9f8b5.zip |
govern remote attach and start
fixes a race where container would start before attach could occur resulting in an error.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r-- | pkg/domain/infra/tunnel/containers.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index cebd332e3..828bfae5b 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -326,7 +326,7 @@ func (ic *ContainerEngine) ContainerLogs(ctx context.Context, containers []strin } func (ic *ContainerEngine) ContainerAttach(ctx context.Context, nameOrId string, options entities.AttachOptions) error { - return containers.Attach(ic.ClientCxt, nameOrId, &options.DetachKeys, nil, bindings.PTrue, options.Stdin, options.Stdout, options.Stderr) + return containers.Attach(ic.ClientCxt, nameOrId, &options.DetachKeys, nil, bindings.PTrue, options.Stdin, options.Stdout, options.Stderr, nil) } func (ic *ContainerEngine) ContainerExec(ctx context.Context, nameOrId string, options entities.ExecOptions) (int, error) { @@ -335,11 +335,14 @@ func (ic *ContainerEngine) ContainerExec(ctx context.Context, nameOrId string, o func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input, output, errput *os.File) error { //nolint attachErr := make(chan error) + attachReady := make(chan bool) go func() { - err := containers.Attach(ic.ClientCxt, name, detachKeys, bindings.PFalse, bindings.PTrue, input, output, errput) + err := containers.Attach(ic.ClientCxt, name, detachKeys, bindings.PFalse, bindings.PTrue, input, output, errput, attachReady) attachErr <- err }() - + // Wait for the attach to actually happen before starting + // the container. + <-attachReady if err := containers.Start(ic.ClientCxt, name, detachKeys); err != nil { return err } |