Merge pull request #17589 from giuseppe/add-warning-rootless-system-service-cgroupv1

system: add warning when running rootless on cgroupv1
This commit is contained in:
OpenShift Merge Robot
2023-02-23 14:25:19 +01:00
committed by GitHub

View File

@ -11,10 +11,12 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/cmd/podman/registry"
api "github.com/containers/podman/v4/pkg/api/server" api "github.com/containers/podman/v4/pkg/api/server"
"github.com/containers/podman/v4/pkg/domain/entities" "github.com/containers/podman/v4/pkg/domain/entities"
"github.com/containers/podman/v4/pkg/domain/infra" "github.com/containers/podman/v4/pkg/domain/infra"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/servicereaper" "github.com/containers/podman/v4/pkg/servicereaper"
"github.com/containers/podman/v4/utils" "github.com/containers/podman/v4/utils"
"github.com/coreos/go-systemd/v22/activation" "github.com/coreos/go-systemd/v22/activation"
@ -106,6 +108,11 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities
// Close the fd right away to not leak it during the entire time of the service. // Close the fd right away to not leak it during the entire time of the service.
devNullfile.Close() devNullfile.Close()
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if rootless.IsRootless() && !cgroupv2 {
logrus.Warnf("Running 'system service' in rootless mode without cgroup v2, containers won't survive a 'system service' restart")
}
if err := utils.MaybeMoveToSubCgroup(); err != nil { if err := utils.MaybeMoveToSubCgroup(); err != nil {
// it is a best effort operation, so just print the // it is a best effort operation, so just print the
// error for debugging purposes. // error for debugging purposes.