diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-06-14 09:21:51 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-06-15 09:51:47 -0400 |
commit | 53c3720de940ace048ca888caa3ab50d82b2f178 (patch) | |
tree | a75873acf6b9066d2bd97042977000e20a05e355 /cmd/podman/main_local.go | |
parent | 670fc030886938b4ee93aa2ddd5db6c947bd975a (diff) | |
download | podman-53c3720de940ace048ca888caa3ab50d82b2f178.tar.gz podman-53c3720de940ace048ca888caa3ab50d82b2f178.tar.bz2 podman-53c3720de940ace048ca888caa3ab50d82b2f178.zip |
Correctly identify the defaults for cgroup-manager
Currently we report cgroupmanager default as systemd, even if the user modified
the libpod.conf. Also cgroupmanager does not work in rootless mode. This
PR correctly identifies the default cgroup manager or reports it is not supported.
Also add homeDir to correctly get the homedir if the $HOME is not set. Will
attempt to get Homedir out of /etc/passwd.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/main_local.go')
-rw-r--r-- | cmd/podman/main_local.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go index 132f35ab5..7a062cb4b 100644 --- a/cmd/podman/main_local.go +++ b/cmd/podman/main_local.go @@ -12,6 +12,7 @@ import ( "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/rootless" "github.com/containers/libpod/pkg/tracing" "github.com/containers/libpod/pkg/util" @@ -25,8 +26,17 @@ import ( const remote = false func init() { - - rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CGroupManager, "cgroup-manager", "", "Cgroup manager to use (cgroupfs or systemd, default systemd)") + cgroupManager := libpod.SystemdCgroupsManager + if runtimeConfig, err := libpod.DefaultRuntimeConfig(); err == nil { + cgroupManager = runtimeConfig.CgroupManager + } + cgroupHelp := "Cgroup manager to use (cgroupfs or systemd)" + cgroupv2, _ := util.IsCgroup2UnifiedMode() + if rootless.IsRootless() && !cgroupv2 { + cgroupManager = "" + cgroupHelp = "Cgroup manager is not supported in rootless mode" + } + rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CGroupManager, "cgroup-manager", cgroupManager, cgroupHelp) // -c is deprecated due to conflict with -c on subcommands rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CpuProfile, "cpu-profile", "", "Path for the cpu profiling results") rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.Config, "config", "", "Path of a libpod config file detailing container server configuration options") |