Use nvidia-container-runtime.experimental as wrapper

This change switches to using nvidia-container-runtime.experimental as the
wrapper name over nvidia-container-runtime-experimental. This is consistent
with upcoming mode-specific binaries.

The wrapper is created at nvidia-container-runtime.experimental.real.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-02-24 17:16:27 +02:00
parent 9435343541
commit ec8a92c17f
10 changed files with 42 additions and 41 deletions

View File

@ -1 +1 @@
# This is a dummy lib file to test nvidia-runtime-experimental
# This is a dummy lib file to test nvidia-runtime.experimental

View File

@ -47,11 +47,11 @@ testing::toolkit::install() {
test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.real"
test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental"
test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental"
test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental.real"
grep -q -E "nvidia driver modules are not yet loaded, invoking runc directly" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental"
grep -q -E "exec runc \".@\"" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental"
grep -q -E "LD_LIBRARY_PATH=/run/nvidia/driver/usr/lib64:\\\$LD_LIBRARY_PATH " "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental"
grep -q -E "nvidia driver modules are not yet loaded, invoking runc directly" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental"
grep -q -E "exec runc \".@\"" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental"
grep -q -E "LD_LIBRARY_PATH=/run/nvidia/driver/usr/lib64:\\\$LD_LIBRARY_PATH " "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental"
test -e "${shared_dir}/usr/local/nvidia/toolkit/.config/nvidia-container-runtime/config.toml"

View File

@ -15,7 +15,7 @@ docker setup \
/run/nvidia/toolkit
```
Configure the `nvidia-container-runtime` as a docker runtime named `NAME`. If the `--runtime-name` flag is not specified, this runtime would be called `nvidia`. A runtime named `nvidia-experimental` will also be configured using the `nvidia-container-runtime-experimental` OCI-compliant runtime shim.
Configure the `nvidia-container-runtime` as a docker runtime named `NAME`. If the `--runtime-name` flag is not specified, this runtime would be called `nvidia`. A runtime named `nvidia-experimental` will also be configured using the `nvidia-container-runtime.experimental` OCI-compliant runtime shim.
Since `--set-as-default` is enabled by default, the specified runtime name will also be set as the default docker runtime. This can be disabled by explicityly specifying `--set-as-default=false`.
@ -48,7 +48,7 @@ containerd setup \
/run/nvidia/toolkit
```
Configure the `nvidia-container-runtime` as a runtime class named `NAME`. If the `--runtime-class` flag is not specified, this runtime would be called `nvidia`. A runtime class named `nvidia-experimental` will also be configured using the `nvidia-container-runtime-experimental` OCI-compliant runtime shim.
Configure the `nvidia-container-runtime` as a runtime class named `NAME`. If the `--runtime-class` flag is not specified, this runtime would be called `nvidia`. A runtime class named `nvidia-experimental` will also be configured using the `nvidia-container-runtime.experimental` OCI-compliant runtime shim.
Adding the `--set-as-default` flag as follows:
```bash

View File

@ -58,7 +58,7 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
setAsDefault: true,
runtimeClass: "nvidia-experimental",
expectedDefaultRuntimeName: nil,
expectedDefaultRuntimeBinary: "/test/runtime/dir/nvidia-container-runtime-experimental",
expectedDefaultRuntimeBinary: "/test/runtime/dir/nvidia-container-runtime.experimental",
},
{
legacyConfig: false,
@ -128,7 +128,7 @@ func TestUpdateV1Config(t *testing.T) {
expectedBinaries := []string{
"/test/runtime/dir/nvidia-container-runtime",
"/test/runtime/dir/nvidia-container-runtime-experimental",
"/test/runtime/dir/nvidia-container-runtime.experimental",
}
testCases := []struct {
@ -195,7 +195,7 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
expectedBinaries := []string{
runcBinary,
"/test/runtime/dir/nvidia-container-runtime",
"/test/runtime/dir/nvidia-container-runtime-experimental",
"/test/runtime/dir/nvidia-container-runtime.experimental",
}
testCases := []struct {
@ -274,7 +274,7 @@ func TestRevertV1Config(t *testing.T) {
"containerd": map[string]interface{}{
"runtimes": map[string]interface{}{
"nvidia": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime"),
"nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime-experimental"),
"nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime.experimental"),
},
},
},
@ -289,7 +289,7 @@ func TestRevertV1Config(t *testing.T) {
"containerd": map[string]interface{}{
"runtimes": map[string]interface{}{
"nvidia": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime"),
"nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime-experimental"),
"nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime.experimental"),
},
"default_runtime": defaultRuntimeV1("/test/runtime/dir/nvidia-container-runtime"),
"default_runtime_name": "nvidia",

View File

@ -92,7 +92,7 @@ func TestUpdateV2Config(t *testing.T) {
expectedBinaries := []string{
"/test/runtime/dir/nvidia-container-runtime",
"/test/runtime/dir/nvidia-container-runtime-experimental",
"/test/runtime/dir/nvidia-container-runtime.experimental",
}
testCases := []struct {
@ -160,7 +160,7 @@ func TestUpdateV2ConfigWithRuncPresent(t *testing.T) {
expectedBinaries := []string{
runcBinary,
"/test/runtime/dir/nvidia-container-runtime",
"/test/runtime/dir/nvidia-container-runtime-experimental",
"/test/runtime/dir/nvidia-container-runtime.experimental",
}
testCases := []struct {
@ -239,7 +239,7 @@ func TestRevertV2Config(t *testing.T) {
"containerd": map[string]interface{}{
"runtimes": map[string]interface{}{
"nvidia": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime"),
"nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime-experimental"),
"nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime.experimental"),
},
},
},
@ -254,7 +254,7 @@ func TestRevertV2Config(t *testing.T) {
"containerd": map[string]interface{}{
"runtimes": map[string]interface{}{
"nvidia": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime"),
"nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime-experimental"),
"nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime.experimental"),
},
"default_runtime_name": "nvidia",
},

View File

@ -38,7 +38,7 @@ const (
nvidiaRuntimeName = "nvidia"
nvidiaRuntimeBinary = "nvidia-container-runtime"
nvidiaExperimentalRuntimeName = "nvidia-experimental"
nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime-experimental"
nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime.experimental"
defaultConfig = "/etc/containerd/config.toml"
defaultSocket = "/run/containerd/containerd.sock"

View File

@ -31,7 +31,7 @@ func TestOptions(t *testing.T) {
{
expectedRuntimeBinaries: map[string]string{
"nvidia": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
{
@ -41,7 +41,7 @@ func TestOptions(t *testing.T) {
expectedDefaultRuntime: "nvidia",
expectedRuntimeBinaries: map[string]string{
"nvidia": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
{
@ -52,7 +52,7 @@ func TestOptions(t *testing.T) {
expectedDefaultRuntime: "nvidia",
expectedRuntimeBinaries: map[string]string{
"nvidia": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
{
@ -63,7 +63,7 @@ func TestOptions(t *testing.T) {
expectedDefaultRuntime: "NAME",
expectedRuntimeBinaries: map[string]string{
"NAME": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
{
@ -73,7 +73,7 @@ func TestOptions(t *testing.T) {
},
expectedRuntimeBinaries: map[string]string{
"NAME": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
{
@ -84,7 +84,7 @@ func TestOptions(t *testing.T) {
expectedDefaultRuntime: "nvidia-experimental",
expectedRuntimeBinaries: map[string]string{
"nvidia": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
{
@ -94,7 +94,7 @@ func TestOptions(t *testing.T) {
},
expectedRuntimeBinaries: map[string]string{
"nvidia": "nvidia-container-runtime",
"nvidia-experimental": "nvidia-container-runtime-experimental",
"nvidia-experimental": "nvidia-container-runtime.experimental",
},
},
}

View File

@ -36,7 +36,7 @@ const (
nvidiaRuntimeName = "nvidia"
nvidiaRuntimeBinary = "nvidia-container-runtime"
nvidiaExperimentalRuntimeName = "nvidia-experimental"
nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime-experimental"
nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime.experimental"
defaultConfig = "/etc/docker/daemon.json"
defaultSocket = "/var/run/docker.sock"
@ -261,7 +261,7 @@ func UpdateConfig(config map[string]interface{}, o *options) error {
return nil
}
//RevertConfig reverts the docker config to remove the nvidia runtime
// RevertConfig reverts the docker config to remove the nvidia runtime
func RevertConfig(config map[string]interface{}) error {
if _, exists := config["default-runtime"]; exists {
defaultRuntime := config["default-runtime"].(string)

View File

@ -89,7 +89,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -106,7 +106,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -123,7 +123,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -146,7 +146,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -172,7 +172,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -192,7 +192,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -212,7 +212,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -240,7 +240,7 @@ func TestUpdateConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},
@ -306,7 +306,7 @@ func TestRevertConfig(t *testing.T) {
"args": []string{},
},
"nvidia-experimental": map[string]interface{}{
"path": "/test/runtime/dir/nvidia-container-runtime-experimental",
"path": "/test/runtime/dir/nvidia-container-runtime.experimental",
"args": []string{},
},
},

View File

@ -29,9 +29,7 @@ const (
nvidiaContainerRuntimeTarget = "nvidia-container-runtime.real"
nvidiaContainerRuntimeWrapper = "nvidia-container-runtime"
nvidiaExperimentalContainerRuntimeSource = "nvidia-container-runtime.experimental"
nvidiaExperimentalContainerRuntimeTarget = nvidiaExperimentalContainerRuntimeSource
nvidiaExperimentalContainerRuntimeWrapper = "nvidia-container-runtime-experimental"
nvidiaExperimentalContainerRuntimeSource = "nvidia-container-runtime.experimental"
)
// installContainerRuntimes sets up the NVIDIA container runtimes, copying the executables
@ -79,16 +77,19 @@ func newNvidiaContainerRuntimeInstaller() *executable {
}
func newNvidiaContainerRuntimeExperimentalInstaller(libraryRoot string) *executable {
source := nvidiaExperimentalContainerRuntimeSource
wrapperName := filepath.Base(source)
dotfileName := wrapperName + ".real"
target := executableTarget{
dotfileName: nvidiaExperimentalContainerRuntimeTarget,
wrapperName: nvidiaExperimentalContainerRuntimeWrapper,
dotfileName: dotfileName,
wrapperName: wrapperName,
}
env := make(map[string]string)
if libraryRoot != "" {
env["LD_LIBRARY_PATH"] = strings.Join([]string{libraryRoot, "$LD_LIBRARY_PATH"}, ":")
}
return newRuntimeInstaller(nvidiaExperimentalContainerRuntimeSource, target, env)
return newRuntimeInstaller(source, target, env)
}
func newRuntimeInstaller(source string, target executableTarget, env map[string]string) *executable {