Skip to content

Commit

Permalink
Remove SkipIfRootless if possible, document other calls
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
<MH: Fixed cherry-pick conflict>
Signed-off-by: Matthew Heon <mheon@redhat.com>
  • Loading branch information
rhatdan authored and mheon committed Oct 14, 2020
1 parent 49b7557 commit 1b5d945
Show file tree
Hide file tree
Showing 27 changed files with 58 additions and 93 deletions.
6 changes: 5 additions & 1 deletion cmd/podman/containers/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/pkg/cgroups"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/rootless"
"github.com/pkg/errors"
Expand Down Expand Up @@ -64,7 +65,10 @@ func pause(cmd *cobra.Command, args []string) error {
errs utils.OutputErrors
)
if rootless.IsRootless() && !registry.IsRemote() {
return errors.New("pause is not supported for rootless containers")
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if !cgroupv2 {
return errors.New("pause is not supported for cgroupv1 rootless containers")
}
}

if len(args) < 1 && !pauseOpts.All {
Expand Down
6 changes: 5 additions & 1 deletion cmd/podman/containers/unpause.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/pkg/cgroups"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/rootless"
"github.com/pkg/errors"
Expand Down Expand Up @@ -62,7 +63,10 @@ func unpause(cmd *cobra.Command, args []string) error {
errs utils.OutputErrors
)
if rootless.IsRootless() && !registry.IsRemote() {
return errors.New("unpause is not supported for rootless containers")
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if !cgroupv2 {
return errors.New("unpause is not supported for cgroupv1 rootless containers")
}
}
if len(args) < 1 && !unPauseOptions.All {
return errors.Errorf("you must provide at least one container name or id")
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ = Describe("Podman checkpoint", func() {
)

BeforeEach(func() {
SkipIfRootless()
SkipIfRootless() //checkpoint not supported in rootless mode
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
Expand Down
5 changes: 1 addition & 4 deletions test/e2e/containers_conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ = Describe("Podman run", func() {
})

It("podman run limits test", func() {
SkipIfRootless()
SkipIfRootlessCgroupsV1()
//containers.conf is set to "nofile=500:500"
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "ulimit", "-n"})
session.WaitWithDefaultTimeout()
Expand Down Expand Up @@ -80,7 +80,6 @@ var _ = Describe("Podman run", func() {
})

It("podman Capabilities in containers.conf", func() {
SkipIfRootless()
os.Setenv("CONTAINERS_CONF", "config/containers.conf")
cap := podmanTest.Podman([]string{"run", ALPINE, "grep", "CapEff", "/proc/self/status"})
cap.WaitWithDefaultTimeout()
Expand All @@ -94,7 +93,6 @@ var _ = Describe("Podman run", func() {
})

It("podman Regular capabilities", func() {
SkipIfRootless()
os.Setenv("CONTAINERS_CONF", "config/containers.conf")
setup := podmanTest.RunTopContainer("test1")
setup.WaitWithDefaultTimeout()
Expand Down Expand Up @@ -176,7 +174,6 @@ var _ = Describe("Podman run", func() {
})

It("podman run containers.conf sysctl test", func() {
SkipIfRootless()
//containers.conf is set to "net.ipv4.ping_group_range=0 1000"
session := podmanTest.Podman([]string{"run", "--rm", fedoraMinimal, "cat", "/proc/sys/net/ipv4/ping_group_range"})
session.WaitWithDefaultTimeout()
Expand Down
6 changes: 2 additions & 4 deletions test/e2e/create_staticip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,19 @@ var _ = Describe("Podman create with --ip flag", func() {
})

It("Podman create --ip with garbage address", func() {
SkipIfRootless()
result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "114232346", ALPINE, "ls"})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
})

It("Podman create --ip with v6 address", func() {
SkipIfRootless()
result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "2001:db8:bad:beef::1", ALPINE, "ls"})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
})

It("Podman create --ip with non-allocatable IP", func() {
SkipIfRootless()
SkipIfRootless() // --ip is not supported in rootless mode
result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "203.0.113.124", ALPINE, "ls"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
Expand Down Expand Up @@ -83,7 +81,7 @@ var _ = Describe("Podman create with --ip flag", func() {
})

It("Podman create two containers with the same IP", func() {
SkipIfRootless()
SkipIfRootless() // --ip not supported in rootless mode
ip := GetRandomIPAddress()
result := podmanTest.Podman([]string{"create", "--name", "test1", "--ip", ip, ALPINE, "sleep", "999"})
result.WaitWithDefaultTimeout()
Expand Down
9 changes: 3 additions & 6 deletions test/e2e/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ var _ = Describe("Podman create", func() {
})

It("create container in pod with IP should fail", func() {
SkipIfRootless()
SkipIfRootless() //Setting IP not supported in rootless mode
name := "createwithstaticip"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expand All @@ -564,7 +564,7 @@ var _ = Describe("Podman create", func() {
})

It("create container in pod with mac should fail", func() {
SkipIfRootless()
SkipIfRootless() //Setting MAC Address not supported in rootless mode
name := "createwithstaticmac"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expand All @@ -576,7 +576,6 @@ var _ = Describe("Podman create", func() {
})

It("create container in pod with network should fail", func() {
SkipIfRootless()
name := "createwithnetwork"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expand All @@ -589,19 +588,17 @@ var _ = Describe("Podman create", func() {
})

It("create container in pod with ports should fail", func() {
SkipIfRootless()
name := "createwithports"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expect(pod.ExitCode()).To(BeZero())

session := podmanTest.Podman([]string{"create", "--pod", name, "-p", "80:80", ALPINE, "top"})
session := podmanTest.Podman([]string{"create", "--pod", name, "-p", "8080:80", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).ToNot(BeZero())
})

It("create container in pod ppublish ports should fail", func() {
SkipIfRootless()
name := "createwithpublishports"
pod := podmanTest.RunTopContainerInPod("", "new:"+name)
pod.WaitWithDefaultTimeout()
Expand Down
8 changes: 0 additions & 8 deletions test/e2e/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var _ = Describe("Podman events", func() {
// These tests are only known to work on Fedora ATM. Other distributions
// will be skipped.
It("podman events", func() {
SkipIfRootless()
SkipIfNotFedora()
_, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand All @@ -53,7 +52,6 @@ var _ = Describe("Podman events", func() {
})

It("podman events with an event filter", func() {
SkipIfRootless()
SkipIfNotFedora()
_, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand All @@ -65,7 +63,6 @@ var _ = Describe("Podman events", func() {

It("podman events with an event filter and container=cid", func() {
Skip("Does not work on v2")
SkipIfRootless()
SkipIfNotFedora()
_, ec, cid := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand All @@ -80,7 +77,6 @@ var _ = Describe("Podman events", func() {
})

It("podman events with a type and filter container=id", func() {
SkipIfRootless()
SkipIfNotFedora()
_, ec, cid := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand All @@ -91,7 +87,6 @@ var _ = Describe("Podman events", func() {
})

It("podman events with a type", func() {
SkipIfRootless()
SkipIfNotFedora()
setup := podmanTest.Podman([]string{"run", "-dt", "--pod", "new:foobarpod", ALPINE, "top"})
setup.WaitWithDefaultTimeout()
Expand All @@ -107,7 +102,6 @@ var _ = Describe("Podman events", func() {
})

It("podman events --since", func() {
SkipIfRootless()
SkipIfNotFedora()
_, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand All @@ -117,7 +111,6 @@ var _ = Describe("Podman events", func() {
})

It("podman events --until", func() {
SkipIfRootless()
SkipIfNotFedora()
_, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand All @@ -130,7 +123,6 @@ var _ = Describe("Podman events", func() {
})

It("podman events format", func() {
SkipIfRootless()
SkipIfNotFedora()
_, ec, _ := podmanTest.RunLsContainer("")
Expect(ec).To(Equal(0))
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ var _ = Describe("Podman mount", func() {
})

It("podman list running container", func() {
SkipIfRootless()
SkipIfRootless() // FIXME: We need to do a podman unshare before executing this code.

setup := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"})
setup.WaitWithDefaultTimeout()
Expand All @@ -212,7 +212,7 @@ var _ = Describe("Podman mount", func() {
})

It("podman list multiple mounted containers", func() {
SkipIfRootless()
SkipIfRootless() // FIXME: We need to do a podman unshare before executing this code.

setup := podmanTest.Podman([]string{"create", ALPINE, "ls"})
setup.WaitWithDefaultTimeout()
Expand Down Expand Up @@ -257,7 +257,7 @@ var _ = Describe("Podman mount", func() {
})

It("podman list mounted container", func() {
SkipIfRootless()
SkipIfRootless() // FIXME: We need to do a podman unshare before executing this code.

setup := podmanTest.Podman([]string{"create", ALPINE, "ls"})
setup.WaitWithDefaultTimeout()
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/network_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ var _ = Describe("Podman network create", func() {
})

It("podman network create with name and IPv6 subnet", func() {
SkipIfRootless()
SkipIfRootless() // FIXME I believe this should work in rootlessmode

var (
results []network.NcList
)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var _ = Describe("Podman network", func() {
})

It("podman network rm", func() {
SkipIfRootless() // FIXME: This one is definitely broken in rootless mode
// Setup, use uuid to prevent conflict with other tests
uuid := stringid.GenerateNonCryptoID()
secondPath := filepath.Join(podmanTest.CNIConfigDir, fmt.Sprintf("%s.conflist", uuid))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ = Describe("Podman pause", func() {
createdState := "created"

BeforeEach(func() {
SkipIfRootless()
SkipIfRootlessCgroupsV1() // Pause is not supported in cgroups v1
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pod_pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var _ = Describe("Podman pod pause", func() {
pausedState := "paused"

BeforeEach(func() {
SkipIfRootless()
SkipIfRootlessCgroupsV1() // Pause is not supported in cgroups v1
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pod_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var _ = Describe("Podman pod stats", func() {

It("podman stats on net=host post", func() {
// --net=host not supported for rootless pods at present
SkipIfRootless()
SkipIfRootlessCgroupsV1() // Pause stats not supported in cgroups v1
podName := "testPod"
podCreate := podmanTest.Podman([]string{"pod", "create", "--net=host", "--name", podName})
podCreate.WaitWithDefaultTimeout()
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,17 @@ var _ = Describe("Podman ps", func() {
})

It("podman ps test with port range", func() {
SkipIfRootless()
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

session = podmanTest.Podman([]string{"run", "-dt", "-p", "1000-1006:1000-1006", ALPINE, "top"})
session = podmanTest.Podman([]string{"run", "-dt", "-p", "2000-2006:2000-2006", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

session = podmanTest.Podman([]string{"ps", "--format", "{{.Ports}}"})
session.WaitWithDefaultTimeout()
Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:1000-1006"))
Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:2000-2006"))
})

It("podman ps sync flag", func() {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var _ = Describe("Podman push", func() {
})

It("podman push to local registry with authorization", func() {
SkipIfRootless()
SkipIfRootless() // FIXME: Creating content in certs.d we use directories in homedir
if podmanTest.Host.Arch == "ppc64le" {
Skip("No registry image for ppc64le")
}
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/run_cgroup_parent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
)

BeforeEach(func() {
SkipIfRootless()
SkipIfRootlessCgroupsV1() // cgroup parent is not supported in cgroups v1
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
Expand Down Expand Up @@ -48,6 +48,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
})

Specify("no --cgroup-parent", func() {
SkipIfRootless() // FIXME This seems to be broken in rootless mode
cgroup := "/libpod_parent"
if !Containerized() && podmanTest.CgroupManager != "cgroupfs" {
cgroup = "/machine.slice"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/run_cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ = Describe("Podman run exit", func() {

It("podman run -d mount cleanup test", func() {
SkipIfRemote("podman-remote does not support mount")
SkipIfRootless()
SkipIfRootless() // FIXME podman mount requires podman unshare first

result := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"})
result.WaitWithDefaultTimeout()
Expand Down
Loading

0 comments on commit 1b5d945

Please sign in to comment.