aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/domain/infra/abi/images.go9
-rw-r--r--pkg/domain/infra/tunnel/containers.go9
-rw-r--r--test/e2e/attach_test.go10
-rw-r--r--test/e2e/libpod_suite_remote_test.go4
-rw-r--r--test/e2e/libpod_suite_test.go4
-rw-r--r--test/e2e/libpod_suite_varlink_test.go4
-rw-r--r--test/e2e/mount_test.go23
7 files changed, 59 insertions, 4 deletions
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index cc62c3f27..25c0c184f 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -191,6 +191,15 @@ func (ir *ImageEngine) Unmount(ctx context.Context, nameOrIDs []string, options
reports := []*entities.ImageUnmountReport{}
for _, img := range images {
report := entities.ImageUnmountReport{Id: img.ID()}
+ mounted, _, err := img.Mounted()
+ if err != nil {
+ // Errors will be caught in Unmount call below
+ // Default assumption to mounted
+ mounted = true
+ }
+ if !mounted {
+ continue
+ }
if err := img.Unmount(options.Force); err != nil {
if options.All && errors.Cause(err) == storage.ErrLayerNotMounted {
logrus.Debugf("Error umounting image %s, storage.ErrLayerNotMounted", img.ID())
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)
}
diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go
index 7b18f71ac..8065f6298 100644
--- a/test/e2e/attach_test.go
+++ b/test/e2e/attach_test.go
@@ -40,7 +40,6 @@ var _ = Describe("Podman attach", func() {
})
It("podman attach to non-running container", func() {
- SkipIfRemote()
session := podmanTest.Podman([]string{"create", "--name", "test1", "-d", "-i", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -51,8 +50,8 @@ var _ = Describe("Podman attach", func() {
})
It("podman container attach to non-running container", func() {
- SkipIfRemote()
session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-d", "-i", ALPINE, "ls"})
+
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -87,7 +86,6 @@ var _ = Describe("Podman attach", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
})
It("podman attach to the latest container", func() {
- SkipIfRemote()
session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", ALPINE, "/bin/sh", "-c", "while true; do echo test1; sleep 1; done"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -96,7 +94,11 @@ var _ = Describe("Podman attach", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- results := podmanTest.Podman([]string{"attach", "-l"})
+ cid := "-l"
+ if IsRemote() {
+ cid = "test2"
+ }
+ results := podmanTest.Podman([]string{"attach", cid})
time.Sleep(2 * time.Second)
results.Signal(syscall.SIGTSTP)
Expect(results.OutputToString()).To(ContainSubstring("test2"))
diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go
index 874789b5e..e74d9bf7c 100644
--- a/test/e2e/libpod_suite_remote_test.go
+++ b/test/e2e/libpod_suite_remote_test.go
@@ -19,6 +19,10 @@ import (
"github.com/onsi/ginkgo"
)
+func IsRemote() bool {
+ return true
+}
+
func SkipIfRemote() {
ginkgo.Skip("This function is not enabled for remote podman")
}
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index bfd898108..0f33798b7 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -12,6 +12,10 @@ import (
. "github.com/onsi/ginkgo"
)
+func IsRemote() bool {
+ return false
+}
+
func SkipIfRemote() {
}
diff --git a/test/e2e/libpod_suite_varlink_test.go b/test/e2e/libpod_suite_varlink_test.go
index 750c8cd09..0d7032429 100644
--- a/test/e2e/libpod_suite_varlink_test.go
+++ b/test/e2e/libpod_suite_varlink_test.go
@@ -19,6 +19,10 @@ import (
"github.com/onsi/ginkgo"
)
+func IsRemote() bool {
+ return true
+}
+
func SkipIfRemote() {
ginkgo.Skip("This function is not enabled for remote podman")
}
diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go
index a2b448337..1fbb92b09 100644
--- a/test/e2e/mount_test.go
+++ b/test/e2e/mount_test.go
@@ -348,6 +348,25 @@ var _ = Describe("Podman mount", func() {
Expect(umount.ExitCode()).To(Equal(0))
})
+ It("podman umount --all", func() {
+ setup := podmanTest.PodmanNoCache([]string{"pull", fedoraMinimal})
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+
+ setup = podmanTest.PodmanNoCache([]string{"pull", ALPINE})
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+
+ mount := podmanTest.Podman([]string{"image", "mount", fedoraMinimal})
+ mount.WaitWithDefaultTimeout()
+ Expect(mount.ExitCode()).To(Equal(0))
+
+ umount := podmanTest.Podman([]string{"image", "umount", "--all"})
+ umount.WaitWithDefaultTimeout()
+ Expect(umount.ExitCode()).To(Equal(0))
+ Expect(len(umount.OutputToStringArray())).To(Equal(1))
+ })
+
It("podman mount many", func() {
setup := podmanTest.PodmanNoCache([]string{"pull", fedoraMinimal})
setup.WaitWithDefaultTimeout()
@@ -402,6 +421,10 @@ var _ = Describe("Podman mount", func() {
Expect(mount.ExitCode()).To(Equal(0))
Expect(mount.OutputToString()).To(Equal(""))
+ umount = podmanTest.PodmanNoCache([]string{"image", "umount", fedoraMinimal, ALPINE})
+ umount.WaitWithDefaultTimeout()
+ Expect(umount.ExitCode()).To(Equal(0))
+
mount1 = podmanTest.PodmanNoCache([]string{"image", "mount", "--all"})
mount1.WaitWithDefaultTimeout()
Expect(mount1.ExitCode()).To(Equal(0))