From df9e8c3ce6a8c093bd0079e576dbd08140c1ab25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 22 Jan 2025 23:17:30 +0100 Subject: [PATCH] Eliminate PodmanSystemdScope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems this utility is not all that generally useful, so eliminate it from the global namespace and use PodmanWithOptions directly. Should not change behavior. Signed-off-by: Miloslav Trmač --- test/e2e/libpod_suite_remote_test.go | 11 ----------- test/e2e/libpod_suite_test.go | 11 ----------- test/e2e/run_test.go | 10 ++++++++-- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index 19bc14f0b0..2034da8850 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -34,17 +34,6 @@ func (p *PodmanTestIntegration) PodmanWithOptions(options PodmanExecOptions, arg return &PodmanSessionIntegration{podmanSession} } -// PodmanSystemdScope runs the podman command in a new systemd scope -func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration { - wrapper := []string{"systemd-run", "--scope"} - if isRootless() { - wrapper = []string{"systemd-run", "--scope", "--user"} - } - return p.PodmanWithOptions(PodmanExecOptions{ - Wrapper: wrapper, - }, args...) -} - func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { defaultFile := "registries.conf" if UsingCacheRegistry() { diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 0ebd27b2a6..41d4ebd1fa 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -26,17 +26,6 @@ func (p *PodmanTestIntegration) PodmanWithOptions(options PodmanExecOptions, arg return &PodmanSessionIntegration{podmanSession} } -// PodmanSystemdScope runs the podman command in a new systemd scope -func (p *PodmanTestIntegration) PodmanSystemdScope(args []string) *PodmanSessionIntegration { - wrapper := []string{"systemd-run", "--scope"} - if isRootless() { - wrapper = []string{"systemd-run", "--scope", "--user"} - } - return p.PodmanWithOptions(PodmanExecOptions{ - Wrapper: wrapper, - }, args...) -} - func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() { defaultFile := "registries.conf" if UsingCacheRegistry() { diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index e9e54e21d7..9e1eec8f4e 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -1704,7 +1704,13 @@ VOLUME %s`, ALPINE, volPath, volPath) } } - container := podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) + scopeOptions := PodmanExecOptions{ + Wrapper: []string{"systemd-run", "--scope"}, + } + if isRootless() { + scopeOptions.Wrapper = append(scopeOptions.Wrapper, "--user") + } + container := podmanTest.PodmanWithOptions(scopeOptions, "run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup") container.WaitWithDefaultTimeout() Expect(container).Should(Exit(0)) checkLines(container.OutputToStringArray()) @@ -1713,7 +1719,7 @@ VOLUME %s`, ALPINE, volPath, volPath) ContainSubstring("Running as unit: "))) // systemd >= 255 // check that --cgroups=split is honored also when a container runs in a pod - container = podmanTest.PodmanSystemdScope([]string{"run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) + container = podmanTest.PodmanWithOptions(scopeOptions, "run", "--rm", "--pod", "new:split-test-pod", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup") container.WaitWithDefaultTimeout() Expect(container).Should(Exit(0)) checkLines(container.OutputToStringArray())