From a3acc4f97775a446f93deeb924ab99b708bcfe88 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 24 Apr 2020 11:41:37 +0200 Subject: podman: add support for --rootfs Signed-off-by: Giuseppe Scrivano --- cmd/podman/containers/create.go | 17 ++++++----------- cmd/podman/containers/run.go | 8 +++++--- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index 8f140e2b8..da550b606 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -75,8 +75,7 @@ func init() { func create(cmd *cobra.Command, args []string) error { var ( - err error - rawImageInput string + err error ) cliVals.Net, err = common.NetFlagsToNetOptions(cmd) if err != nil { @@ -92,20 +91,16 @@ func create(cmd *cobra.Command, args []string) error { defer errorhandling.SyncQuiet(cidFile) } - if rfs := cliVals.RootFS; !rfs { - rawImageInput = args[0] - } - if err := createInit(cmd); err != nil { return err } - if err := pullImage(args[0]); err != nil { - return err + if !cliVals.RootFS { + if err := pullImage(args[0]); err != nil { + return err + } } - - //TODO rootfs still - s := specgen.NewSpecGenerator(rawImageInput) + s := specgen.NewSpecGenerator(args[0], cliVals.RootFS) if err := common.FillOutSpecGen(s, &cliVals, args); err != nil { return err } diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 409b72198..e3fe4cd0b 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -104,8 +104,10 @@ func run(cmd *cobra.Command, args []string) error { return err } - if err := pullImage(args[0]); err != nil { - return err + if !cliVals.RootFS { + if err := pullImage(args[0]); err != nil { + return err + } } // If -i is not set, clear stdin @@ -136,7 +138,7 @@ func run(cmd *cobra.Command, args []string) error { } runOpts.Detach = cliVals.Detach runOpts.DetachKeys = cliVals.DetachKeys - s := specgen.NewSpecGenerator(args[0]) + s := specgen.NewSpecGenerator(args[0], cliVals.RootFS) if err := common.FillOutSpecGen(s, &cliVals, args); err != nil { return err } -- cgit v1.2.3-54-g00ecf From 2e6a62fc380976b06fc9a57892b4070528b94b60 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 24 Apr 2020 11:56:19 +0200 Subject: podman: fix --cgroups=disabled Signed-off-by: Giuseppe Scrivano --- cmd/podman/common/specgen.go | 6 +++--- test/e2e/run_test.go | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index b90030f7f..fda11c0af 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -119,13 +119,13 @@ func getIOLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) ( func getPidsLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxPids, error) { pids := &specs.LinuxPids{} hasLimits := false + if c.CGroupsMode == "disabled" && c.PIDsLimit > 0 { + return nil, nil + } if c.PIDsLimit > 0 { pids.Limit = c.PIDsLimit hasLimits = true } - if c.CGroupsMode == "disabled" && c.PIDsLimit > 0 { - s.ResourceLimits.Pids.Limit = -1 - } if !hasLimits { return nil, nil } diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index df97ddf69..92db37096 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -937,7 +937,6 @@ USER mail` }) It("podman run with cgroups=disabled runs without cgroups", func() { - Skip(v2fail) SkipIfRemote() SkipIfRootless() // Only works on crun -- cgit v1.2.3-54-g00ecf From a1f73d095400f13999e61578567f338a9f13a008 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 24 Apr 2020 12:25:18 +0200 Subject: podman: fix podman --group-add Signed-off-by: Giuseppe Scrivano --- cmd/podman/common/specgen.go | 1 + test/e2e/run_test.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/podman') diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index fda11c0af..e14fd78b4 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -449,6 +449,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string } s.CgroupParent = c.CGroupParent s.CgroupsMode = c.CGroupsMode + s.Groups = c.GroupAdd // TODO WTF //cgroup := &cc.CgroupConfig{ // Cgroupns: c.String("cgroupns"), diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 735fc1d5d..6386b8a70 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -566,7 +566,6 @@ var _ = Describe("Podman run", func() { }) It("podman run with group-add", func() { - Skip(v2fail) SkipIfRootless() session := podmanTest.Podman([]string{"run", "--rm", "--group-add=audio", "--group-add=nogroup", "--group-add=777", ALPINE, "id"}) session.WaitWithDefaultTimeout() -- cgit v1.2.3-54-g00ecf From 145d74716c9cbc8d6c83be5a8f6a575543d10d06 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 24 Apr 2020 12:45:00 +0200 Subject: podman: fix --http-proxy Signed-off-by: Giuseppe Scrivano --- cmd/podman/common/specgen.go | 16 ++++++++++++++++ test/e2e/run_test.go | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'cmd/podman') diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index e14fd78b4..9e8a271ae 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -288,7 +288,23 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string if c.EnvHost { env = envLib.Join(env, osEnv) + } else if c.HTTPProxy { + for _, envSpec := range []string{ + "http_proxy", + "HTTP_PROXY", + "https_proxy", + "HTTPS_PROXY", + "ftp_proxy", + "FTP_PROXY", + "no_proxy", + "NO_PROXY", + } { + if v, ok := osEnv[envSpec]; ok { + env[envSpec] = v + } + } } + // env-file overrides any previous variables for _, f := range c.EnvFile { fileEnv, err := envLib.ParseFile(f) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 6386b8a70..7745bcf6a 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -877,7 +877,6 @@ USER mail` }) It("podman run --http-proxy test", func() { - Skip(v2fail) os.Setenv("http_proxy", "1.2.3.4") session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "http_proxy"}) session.WaitWithDefaultTimeout() -- cgit v1.2.3-54-g00ecf From 3eeb03d1f970478961acf21cecfdf90d5a75043f Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 24 Apr 2020 12:50:13 +0200 Subject: podman: fix --log-opt=path=%s Signed-off-by: Giuseppe Scrivano --- cmd/podman/common/specgen.go | 9 ++++++++- test/e2e/run_test.go | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 9e8a271ae..abec1213c 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -602,7 +602,14 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string if len(split) < 2 { return errors.Errorf("invalid log option %q", o) } - logOpts[split[0]] = split[1] + switch { + case split[0] == "driver": + s.LogConfiguration.Driver = split[1] + case split[0] == "path": + s.LogConfiguration.Path = split[1] + default: + logOpts[split[0]] = split[1] + } } s.LogConfiguration.Options = logOpts s.Name = c.Name diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 7745bcf6a..7d4039819 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -469,7 +469,6 @@ var _ = Describe("Podman run", func() { }) It("podman run log-opt", func() { - Skip(v2fail) log := filepath.Join(podmanTest.TempDir, "/container.log") session := podmanTest.Podman([]string{"run", "--rm", "--log-opt", fmt.Sprintf("path=%s", log), ALPINE, "ls"}) session.WaitWithDefaultTimeout() -- cgit v1.2.3-54-g00ecf