Skip to content

Commit

Permalink
libpod/config: default: use crun on Cgroups v2
Browse files Browse the repository at this point in the history
When running on a node with Cgroups v2, default to using `crun` instead
of `runc`.  Note that this only impacts the hard-coded default config.
No user config will be over-written.

Fixes: #4463
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Nov 7, 2019
1 parent 2e2d82c commit 709ad91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 7 additions & 2 deletions libpod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ runc = [
]

crun = [
"/usr/bin/crun",
"/usr/local/bin/crun",
"/usr/bin/crun",
"/usr/sbin/crun",
"/usr/local/bin/crun",
"/usr/local/sbin/crun",
"/sbin/crun",
"/bin/crun",
"/run/current-system/sw/bin/crun",
]

# The [runtimes] table MUST be the last thing in this file.
Expand Down
17 changes: 16 additions & 1 deletion libpod/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/events"
"github.com/containers/libpod/pkg/cgroups"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/util"
"github.com/containers/storage"
Expand Down Expand Up @@ -47,6 +48,12 @@ func defaultConfigFromMemory() (*Config, error) {
c.ImageDefaultTransport = _defaultTransport
c.StateType = define.BoltDBStateStore
c.OCIRuntime = "runc"

// If we're running on cgroups v2, default to using crun.
if onCgroupsv2, _ := cgroups.IsCgroup2UnifiedMode(); onCgroupsv2 {
c.OCIRuntime = "crun"
}

c.OCIRuntimes = map[string][]string{
"runc": {
"/usr/bin/runc",
Expand All @@ -58,7 +65,15 @@ func defaultConfigFromMemory() (*Config, error) {
"/usr/lib/cri-o-runc/sbin/runc",
"/run/current-system/sw/bin/runc",
},
// TODO - should we add "crun" defaults here as well?
"crun": {
"/usr/bin/crun",
"/usr/sbin/crun",
"/usr/local/bin/crun",
"/usr/local/sbin/crun",
"/sbin/crun",
"/bin/crun",
"/run/current-system/sw/bin/crun",
},
}
c.ConmonPath = []string{
"/usr/libexec/podman/conmon",
Expand Down

0 comments on commit 709ad91

Please sign in to comment.