buildah: new global option --cgroup-manager
allow to override the cgroup manager with a global option --cgroup-manager=MANAGER that has the same semantic as Podman. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
87f6c19079
commit
5a999cfbd5
|
@ -39,6 +39,7 @@ type globalFlags struct {
|
|||
cpuProfileFile *os.File
|
||||
MemoryProfile string
|
||||
UserShortNameAliasConfPath string
|
||||
CgroupManager string
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
|
@ -77,6 +78,13 @@ func init() {
|
|||
defaultStoreDriverOptions = optionSlice
|
||||
}
|
||||
|
||||
containerConfig, err := config.Default()
|
||||
if err != nil {
|
||||
logrus.Errorf(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
containerConfig.CheckCgroupsAndAdjustConfig()
|
||||
|
||||
cobra.OnInitialize(initConfig)
|
||||
// Disable the implicit `completion` command in cobra.
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
|
@ -89,6 +97,7 @@ func init() {
|
|||
rootCmd.PersistentFlags().StringVar(&globalFlagResults.UserShortNameAliasConfPath, "short-name-alias-conf", "", "path to short name alias cache file (not usually used)")
|
||||
rootCmd.PersistentFlags().StringVar(&globalFlagResults.Root, "root", storageOptions.GraphRoot, "storage root dir")
|
||||
rootCmd.PersistentFlags().StringVar(&globalFlagResults.RunRoot, "runroot", storageOptions.RunRoot, "storage state dir")
|
||||
rootCmd.PersistentFlags().StringVar(&globalFlagResults.CgroupManager, "cgroup-manager", containerConfig.Engine.CgroupManager, "cgroup manager")
|
||||
rootCmd.PersistentFlags().StringVar(&globalFlagResults.StorageDriver, "storage-driver", storageOptions.GraphDriverName, "storage-driver")
|
||||
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.StorageOpts, "storage-opt", defaultStoreDriverOptions, "storage driver option")
|
||||
rootCmd.PersistentFlags().StringSliceVar(&globalFlagResults.UserNSUID, "userns-uid-map", []string{}, "default `ctrID:hostID:length` UID mapping to use")
|
||||
|
|
|
@ -160,6 +160,7 @@ func runCmd(c *cobra.Command, args []string, iopts runInputOptions) error {
|
|||
options.Mounts = mounts
|
||||
// Run() will automatically clean them up.
|
||||
options.ExternalImageMounts = mountedImages
|
||||
options.CgroupManager = globalFlagResults.CgroupManager
|
||||
|
||||
runerr := builder.Run(args, options)
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ return 1
|
|||
--version -v
|
||||
"
|
||||
local options_with_args="
|
||||
--cgroup-manager
|
||||
--registries-conf
|
||||
--registries-conf-dir
|
||||
--root
|
||||
|
@ -200,6 +201,10 @@ return 1
|
|||
COMPREPLY=($(compgen -W 'devicemapper overlay2' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
--cgroup-manager)
|
||||
COMPREPLY=($(compgen -W 'cgroupfs systemd' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
$(__buildah_to_extglob "$options_with_args"))
|
||||
return
|
||||
;;
|
||||
|
|
|
@ -20,6 +20,13 @@ The Buildah package provides a command line tool which can be used to:
|
|||
|
||||
## OPTIONS
|
||||
|
||||
**--cgroup-manager**=*manager*
|
||||
|
||||
The CGroup manager to use for container cgroups. Supported values are cgroupfs or systemd. Default is systemd unless overridden in the containers.conf file.
|
||||
|
||||
Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
|
||||
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.
|
||||
|
||||
**--log-level** **value**
|
||||
|
||||
The log level to be used. Either "trace", "debug", "info", "warn", "error", "fatal", or "panic", defaulting to "warn".
|
||||
|
|
2
run.go
2
run.go
|
@ -157,6 +157,8 @@ type RunOptions struct {
|
|||
ExternalImageMounts []string
|
||||
// System context of current build
|
||||
SystemContext *types.SystemContext
|
||||
// CgroupManager to use for running OCI containers
|
||||
CgroupManager string
|
||||
}
|
||||
|
||||
// RunMountArtifacts are the artifacts created when using a run mount.
|
||||
|
|
Loading…
Reference in New Issue