diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-07-13 09:10:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 09:10:57 +0000 |
commit | 4df6122aaa3bc858e9488d366a2c9c91b6671170 (patch) | |
tree | 9c03ee40d0d7c6cd29c881245a3eb24159f8b10b /pkg | |
parent | 6323af78e785f2713497f934f22f5f26719d2175 (diff) | |
parent | e3419c03245c5639d457cb27f4081cee400f3a36 (diff) | |
download | podman-4df6122aaa3bc858e9488d366a2c9c91b6671170.tar.gz podman-4df6122aaa3bc858e9488d366a2c9c91b6671170.tar.bz2 podman-4df6122aaa3bc858e9488d366a2c9c91b6671170.zip |
Merge pull request #14904 from giuseppe/move-to-subcgroup-in-a-container
abi: create new cgroup when running in a container
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/domain/infra/abi/system.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 0faae01c8..3389abd88 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -67,6 +67,22 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) { } func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool) error { + runsUnderSystemd := utils.RunsOnSystemd() + if !runsUnderSystemd { + isPid1 := os.Getpid() == 1 + if _, found := os.LookupEnv("container"); isPid1 || found { + if err := utils.MaybeMoveToSubCgroup(); err != nil { + // it is a best effort operation, so just print the + // error for debugging purposes. + logrus.Debugf("Could not move to subcgroup: %v", err) + } + } + } + + if !rootless.IsRootless() { + return nil + } + // do it only after podman has already re-execed and running with uid==0. hasCapSysAdmin, err := unshare.HasCapSysAdmin() if err != nil { @@ -82,7 +98,6 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool) if err != nil { return err } - runsUnderSystemd := utils.RunsOnSystemd() unitName := fmt.Sprintf("podman-%d.scope", os.Getpid()) if runsUnderSystemd || conf.Engine.CgroupManager == config.SystemdCgroupsManager { if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil { |