summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-09-21 17:42:22 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-09-22 06:19:59 -0400
commitf949cfddaa0ff47247df8424d7ddb793088b49e2 (patch)
tree5b98eb6c0e90b268a7a0ab571f191deceb371ab6 /pkg/domain/infra
parentfffcc25d8dfab8c6059c229177286f462d909b8d (diff)
downloadpodman-f949cfddaa0ff47247df8424d7ddb793088b49e2.tar.gz
podman-f949cfddaa0ff47247df8424d7ddb793088b49e2.tar.bz2
podman-f949cfddaa0ff47247df8424d7ddb793088b49e2.zip
Fix up attach tests for podman remote
When we execute podman-remote attach, we were not checking if the container was in the correct state, this is leading to timeouts and we had turned off remote testing. Also added an IfRemote() function so we can turn on more tests when using the "-l" flag for local, but use container name for remote. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/tunnel/containers.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 3e99b73b6..d0f90d900 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -389,6 +389,15 @@ func (ic *ContainerEngine) ContainerLogs(_ context.Context, nameOrIDs []string,
}
func (ic *ContainerEngine) ContainerAttach(ctx context.Context, nameOrID string, options entities.AttachOptions) error {
+ ctrs, err := getContainersByContext(ic.ClientCxt, false, false, []string{nameOrID})
+ if err != nil {
+ return err
+ }
+ ctr := ctrs[0]
+ if ctr.State != define.ContainerStateRunning.String() {
+ return errors.Errorf("you can only attach to running containers")
+ }
+
return containers.Attach(ic.ClientCxt, nameOrID, &options.DetachKeys, nil, bindings.PTrue, options.Stdin, options.Stdout, options.Stderr, nil)
}