mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-28 06:52:34 +00:00
Allow same envars for all runtime configs
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
c3c1d19a5c
commit
dcbf4b4f2a
@ -116,51 +116,40 @@ func main() {
|
|||||||
commonFlags := []cli.Flag{
|
commonFlags := []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Aliases: []string{"c"},
|
|
||||||
Usage: "Path to the containerd config file",
|
Usage: "Path to the containerd config file",
|
||||||
Value: defaultConfig,
|
Value: defaultConfig,
|
||||||
Destination: &options.config,
|
Destination: &options.config,
|
||||||
EnvVars: []string{"CONTAINERD_CONFIG"},
|
EnvVars: []string{"CONTAINERD_CONFIG", "RUNTIME_CONFIG"},
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "socket",
|
Name: "socket",
|
||||||
Aliases: []string{"s"},
|
|
||||||
Usage: "Path to the containerd socket file",
|
Usage: "Path to the containerd socket file",
|
||||||
Value: defaultSocket,
|
Value: defaultSocket,
|
||||||
Destination: &options.socket,
|
Destination: &options.socket,
|
||||||
EnvVars: []string{"CONTAINERD_SOCKET"},
|
EnvVars: []string{"CONTAINERD_SOCKET", "RUNTIME_SOCKET"},
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "runtime-class",
|
|
||||||
Aliases: []string{"r"},
|
|
||||||
Usage: "The name of the runtime class to set for the nvidia-container-runtime",
|
|
||||||
Value: defaultRuntimeClass,
|
|
||||||
Destination: &options.runtimeClass,
|
|
||||||
EnvVars: []string{"CONTAINERD_RUNTIME_CLASS"},
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "runtime-type",
|
|
||||||
Usage: "The runtime_type to use for the configured runtime classes",
|
|
||||||
Value: defaultRuntmeType,
|
|
||||||
Destination: &options.runtimeType,
|
|
||||||
EnvVars: []string{"CONTAINERD_RUNTIME_TYPE"},
|
|
||||||
},
|
|
||||||
// The flags below are only used by the 'setup' command.
|
|
||||||
&cli.BoolFlag{
|
|
||||||
Name: "set-as-default",
|
|
||||||
Aliases: []string{"d"},
|
|
||||||
Usage: "Set nvidia-container-runtime as the default runtime",
|
|
||||||
Value: defaultSetAsDefault,
|
|
||||||
Destination: &options.setAsDefault,
|
|
||||||
EnvVars: []string{"CONTAINERD_SET_AS_DEFAULT"},
|
|
||||||
Hidden: true,
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "restart-mode",
|
Name: "restart-mode",
|
||||||
Usage: "Specify how containerd should be restarted; If 'none' is selected, it will not be restarted [signal | systemd | none]",
|
Usage: "Specify how containerd should be restarted; If 'none' is selected, it will not be restarted [signal | systemd | none]",
|
||||||
Value: defaultRestartMode,
|
Value: defaultRestartMode,
|
||||||
Destination: &options.restartMode,
|
Destination: &options.restartMode,
|
||||||
EnvVars: []string{"CONTAINERD_RESTART_MODE"},
|
EnvVars: []string{"CONTAINERD_RESTART_MODE", "RUNTIME_RESTART_MODE"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "runtime-class",
|
||||||
|
Aliases: []string{"runtime-name", "nvidia-runtime-name"},
|
||||||
|
Usage: "The name of the runtime class to set for the nvidia-container-runtime",
|
||||||
|
Value: defaultRuntimeClass,
|
||||||
|
Destination: &options.runtimeClass,
|
||||||
|
EnvVars: []string{"CONTAINERD_RUNTIME_CLASS", "NVIDIA_RUNTIME_NAME"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "set-as-default",
|
||||||
|
Usage: "Set nvidia-container-runtime as the default runtime",
|
||||||
|
Value: defaultSetAsDefault,
|
||||||
|
Destination: &options.setAsDefault,
|
||||||
|
EnvVars: []string{"CONTAINERD_SET_AS_DEFAULT", "NVIDIA_RUNTIME_SET_AS_DEFAULT"},
|
||||||
|
Hidden: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "host-root",
|
Name: "host-root",
|
||||||
@ -175,6 +164,13 @@ func main() {
|
|||||||
Destination: &options.useLegacyConfig,
|
Destination: &options.useLegacyConfig,
|
||||||
EnvVars: []string{"CONTAINERD_USE_LEGACY_CONFIG"},
|
EnvVars: []string{"CONTAINERD_USE_LEGACY_CONFIG"},
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "runtime-type",
|
||||||
|
Usage: "The runtime_type to use for the configured runtime classes",
|
||||||
|
Value: defaultRuntmeType,
|
||||||
|
Destination: &options.runtimeType,
|
||||||
|
EnvVars: []string{"CONTAINERD_RUNTIME_TYPE"},
|
||||||
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "nvidia-container-runtime-modes.cdi.annotation-prefixes",
|
Name: "nvidia-container-runtime-modes.cdi.annotation-prefixes",
|
||||||
Destination: &options.ContainerRuntimeModesCDIAnnotationPrefixes,
|
Destination: &options.ContainerRuntimeModesCDIAnnotationPrefixes,
|
||||||
|
@ -43,6 +43,7 @@ const (
|
|||||||
|
|
||||||
// Config-based settings
|
// Config-based settings
|
||||||
defaultConfig = "/etc/crio/crio.conf"
|
defaultConfig = "/etc/crio/crio.conf"
|
||||||
|
defaultSocket = "/var/run/crio/crio.sock"
|
||||||
defaultRuntimeClass = "nvidia"
|
defaultRuntimeClass = "nvidia"
|
||||||
defaultSetAsDefault = true
|
defaultSetAsDefault = true
|
||||||
defaultRestartMode = restartModeSystemd
|
defaultRestartMode = restartModeSystemd
|
||||||
@ -58,6 +59,7 @@ type options struct {
|
|||||||
runtimeDir string
|
runtimeDir string
|
||||||
|
|
||||||
config string
|
config string
|
||||||
|
socket string
|
||||||
runtimeClass string
|
runtimeClass string
|
||||||
setAsDefault bool
|
setAsDefault bool
|
||||||
restartMode string
|
restartMode string
|
||||||
@ -104,9 +106,53 @@ func main() {
|
|||||||
// only require the user to specify one set of flags for both 'startup'
|
// only require the user to specify one set of flags for both 'startup'
|
||||||
// and 'cleanup' to simplify things.
|
// and 'cleanup' to simplify things.
|
||||||
commonFlags := []cli.Flag{
|
commonFlags := []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "config",
|
||||||
|
Usage: "Path to the cri-o config file",
|
||||||
|
Value: defaultConfig,
|
||||||
|
Destination: &options.config,
|
||||||
|
EnvVars: []string{"CRIO_CONFIG", "RUNTIME_CONFIG"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "socket",
|
||||||
|
Usage: "Path to the crio socket file",
|
||||||
|
Value: "",
|
||||||
|
Destination: &options.socket,
|
||||||
|
EnvVars: []string{"CRIO_SOCKET", "RUNTIME_SOCKET"},
|
||||||
|
Hidden: true,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "restart-mode",
|
||||||
|
Usage: "Specify how cri-o should be restarted; If 'none' is selected, it will not be restarted [systemd | none]",
|
||||||
|
Value: defaultRestartMode,
|
||||||
|
Destination: &options.restartMode,
|
||||||
|
EnvVars: []string{"CRIO_RESTART_MODE", "RUNTIME_RESTART_MODE"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "runtime-class",
|
||||||
|
Aliases: []string{"runtime-name", "nvidia-runtime-name"},
|
||||||
|
Usage: "The name of the runtime class to set for the nvidia-container-runtime",
|
||||||
|
Value: defaultRuntimeClass,
|
||||||
|
Destination: &options.runtimeClass,
|
||||||
|
EnvVars: []string{"CRIO_RUNTIME_CLASS", "NVIDIA_RUNTIME_NAME"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "set-as-default",
|
||||||
|
Usage: "Set nvidia-container-runtime as the default runtime",
|
||||||
|
Value: defaultSetAsDefault,
|
||||||
|
Destination: &options.setAsDefault,
|
||||||
|
EnvVars: []string{"CRIO_SET_AS_DEFAULT", "NVIDIA_RUNTIME_SET_AS_DEFAULT"},
|
||||||
|
Hidden: true,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "host-root",
|
||||||
|
Usage: "Specify the path to the host root to be used when restarting crio using systemd",
|
||||||
|
Value: defaultHostRootMount,
|
||||||
|
Destination: &options.hostRootMount,
|
||||||
|
EnvVars: []string{"HOST_ROOT_MOUNT"},
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "hooks-dir",
|
Name: "hooks-dir",
|
||||||
Aliases: []string{"d"},
|
|
||||||
Usage: "path to the cri-o hooks directory",
|
Usage: "path to the cri-o hooks directory",
|
||||||
Value: defaultHooksDir,
|
Value: defaultHooksDir,
|
||||||
Destination: &options.hooksDir,
|
Destination: &options.hooksDir,
|
||||||
@ -115,7 +161,6 @@ func main() {
|
|||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "hook-filename",
|
Name: "hook-filename",
|
||||||
Aliases: []string{"f"},
|
|
||||||
Usage: "filename of the cri-o hook that will be created / removed in the hooks directory",
|
Usage: "filename of the cri-o hook that will be created / removed in the hooks directory",
|
||||||
Value: defaultHookFilename,
|
Value: defaultHookFilename,
|
||||||
Destination: &options.hookFilename,
|
Destination: &options.hookFilename,
|
||||||
@ -129,43 +174,7 @@ func main() {
|
|||||||
Destination: &options.configMode,
|
Destination: &options.configMode,
|
||||||
EnvVars: []string{"CRIO_CONFIG_MODE"},
|
EnvVars: []string{"CRIO_CONFIG_MODE"},
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "config",
|
|
||||||
Usage: "Path to the cri-o config file",
|
|
||||||
Value: defaultConfig,
|
|
||||||
Destination: &options.config,
|
|
||||||
EnvVars: []string{"CRIO_CONFIG"},
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "runtime-class",
|
|
||||||
Usage: "The name of the runtime class to set for the nvidia-container-runtime",
|
|
||||||
Value: defaultRuntimeClass,
|
|
||||||
Destination: &options.runtimeClass,
|
|
||||||
EnvVars: []string{"CRIO_RUNTIME_CLASS"},
|
|
||||||
},
|
|
||||||
// The flags below are only used by the 'setup' command.
|
// The flags below are only used by the 'setup' command.
|
||||||
&cli.BoolFlag{
|
|
||||||
Name: "set-as-default",
|
|
||||||
Usage: "Set nvidia-container-runtime as the default runtime",
|
|
||||||
Value: defaultSetAsDefault,
|
|
||||||
Destination: &options.setAsDefault,
|
|
||||||
EnvVars: []string{"CRIO_SET_AS_DEFAULT"},
|
|
||||||
Hidden: true,
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "restart-mode",
|
|
||||||
Usage: "Specify how cri-o should be restarted; If 'none' is selected, it will not be restarted [systemd | none]",
|
|
||||||
Value: defaultRestartMode,
|
|
||||||
Destination: &options.restartMode,
|
|
||||||
EnvVars: []string{"CRIO_RESTART_MODE"},
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "host-root",
|
|
||||||
Usage: "Specify the path to the host root to be used when restarting crio using systemd",
|
|
||||||
Value: defaultHostRootMount,
|
|
||||||
Destination: &options.hostRootMount,
|
|
||||||
EnvVars: []string{"HOST_ROOT_MOUNT"},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the subcommand flags with the common subcommand flags
|
// Update the subcommand flags with the common subcommand flags
|
||||||
|
@ -45,6 +45,7 @@ const (
|
|||||||
// defaultRuntimeName specifies the NVIDIA runtime to be use as the default runtime if setting the default runtime is enabled
|
// defaultRuntimeName specifies the NVIDIA runtime to be use as the default runtime if setting the default runtime is enabled
|
||||||
defaultRuntimeName = nvidiaRuntimeName
|
defaultRuntimeName = nvidiaRuntimeName
|
||||||
defaultRestartMode = restartModeSignal
|
defaultRestartMode = restartModeSignal
|
||||||
|
defaultHostRootMount = "/host"
|
||||||
|
|
||||||
reloadBackoff = 5 * time.Second
|
reloadBackoff = 5 * time.Second
|
||||||
maxReloadAttempts = 6
|
maxReloadAttempts = 6
|
||||||
@ -67,6 +68,7 @@ type options struct {
|
|||||||
setAsDefault bool
|
setAsDefault bool
|
||||||
runtimeDir string
|
runtimeDir string
|
||||||
restartMode string
|
restartMode string
|
||||||
|
hostRootMount string
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -109,44 +111,50 @@ func main() {
|
|||||||
commonFlags := []cli.Flag{
|
commonFlags := []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Aliases: []string{"c"},
|
|
||||||
Usage: "Path to docker config file",
|
Usage: "Path to docker config file",
|
||||||
Value: defaultConfig,
|
Value: defaultConfig,
|
||||||
Destination: &options.config,
|
Destination: &options.config,
|
||||||
EnvVars: []string{"DOCKER_CONFIG"},
|
EnvVars: []string{"DOCKER_CONFIG", "RUNTIME_CONFIG"},
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "socket",
|
Name: "socket",
|
||||||
Aliases: []string{"s"},
|
|
||||||
Usage: "Path to the docker socket file",
|
Usage: "Path to the docker socket file",
|
||||||
Value: defaultSocket,
|
Value: defaultSocket,
|
||||||
Destination: &options.socket,
|
Destination: &options.socket,
|
||||||
EnvVars: []string{"DOCKER_SOCKET"},
|
EnvVars: []string{"DOCKER_SOCKET", "RUNTIME_SOCKET"},
|
||||||
},
|
|
||||||
// The flags below are only used by the 'setup' command.
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "runtime-name",
|
|
||||||
Aliases: []string{"r"},
|
|
||||||
Usage: "Specify the name of the `nvidia` runtime. If set-as-default is selected, the runtime is used as the default runtime.",
|
|
||||||
Value: defaultRuntimeName,
|
|
||||||
Destination: &options.runtimeName,
|
|
||||||
EnvVars: []string{"DOCKER_RUNTIME_NAME"},
|
|
||||||
},
|
|
||||||
&cli.BoolFlag{
|
|
||||||
Name: "set-as-default",
|
|
||||||
Aliases: []string{"d"},
|
|
||||||
Usage: "Set the `nvidia` runtime as the default runtime. If --runtime-name is specified as `nvidia-experimental` the experimental runtime is set as the default runtime instead",
|
|
||||||
Value: defaultSetAsDefault,
|
|
||||||
Destination: &options.setAsDefault,
|
|
||||||
EnvVars: []string{"DOCKER_SET_AS_DEFAULT"},
|
|
||||||
Hidden: true,
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "restart-mode",
|
Name: "restart-mode",
|
||||||
Usage: "Specify how docker should be restarted; If 'none' is selected it will not be restarted [signal | none]",
|
Usage: "Specify how docker should be restarted; If 'none' is selected it will not be restarted [signal | none]",
|
||||||
Value: defaultRestartMode,
|
Value: defaultRestartMode,
|
||||||
Destination: &options.restartMode,
|
Destination: &options.restartMode,
|
||||||
EnvVars: []string{"DOCKER_RESTART_MODE"},
|
EnvVars: []string{"DOCKER_RESTART_MODE", "RUNTIME_RESTART_MODE"},
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "host-root",
|
||||||
|
Usage: "Specify the path to the host root to be used when restarting docker using systemd",
|
||||||
|
Value: defaultHostRootMount,
|
||||||
|
Destination: &options.hostRootMount,
|
||||||
|
EnvVars: []string{"HOST_ROOT_MOUNT"},
|
||||||
|
// Restart using systemd is currently not supported.
|
||||||
|
// We hide this option for the time being.
|
||||||
|
Hidden: true,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "runtime-name",
|
||||||
|
Aliases: []string{"runtime-class", "nvidia-runtime-name"},
|
||||||
|
Usage: "Specify the name of the `nvidia` runtime. If set-as-default is selected, the runtime is used as the default runtime.",
|
||||||
|
Value: defaultRuntimeName,
|
||||||
|
Destination: &options.runtimeName,
|
||||||
|
EnvVars: []string{"DOCKER_RUNTIME_NAME", "NVIDIA_RUNTIME_NAME"},
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "set-as-default",
|
||||||
|
Usage: "Set the `nvidia` runtime as the default runtime. If --runtime-name is specified as `nvidia-experimental` the experimental runtime is set as the default runtime instead",
|
||||||
|
Value: defaultSetAsDefault,
|
||||||
|
Destination: &options.setAsDefault,
|
||||||
|
EnvVars: []string{"DOCKER_SET_AS_DEFAULT", "NVIDIA_RUNTIME_SET_AS_DEFAULT"},
|
||||||
|
Hidden: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user