Extract options from default runtime if runc does not exist

This change updates the logic to populate the options for the
nvidia runtime configs added to containerd or crio from a default runtime
if this is specified and a runc entry is not found.

This allows the default runtime values for settings such as SystemdCgroup
to be applied correctly.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2024-07-02 10:26:41 +02:00
parent 15c884e99f
commit b8389283d5
11 changed files with 623 additions and 27 deletions

View File

@@ -21,6 +21,7 @@ import (
"testing"
"github.com/pelletier/go-toml"
testlog "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/require"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/containerd"
@@ -28,6 +29,7 @@ import (
)
func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
logger, _ := testlog.NewNullLogger()
const runtimeDir = "/test/runtime/dir"
testCases := []struct {
@@ -94,6 +96,7 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
require.NoError(t, err, "%d: %v", i, tc)
v1 := &containerd.ConfigV1{
Logger: logger,
Tree: config,
UseDefaultRuntimeName: !tc.legacyConfig,
RuntimeType: runtimeType,
@@ -125,6 +128,7 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) {
}
func TestUpdateV1Config(t *testing.T) {
logger, _ := testlog.NewNullLogger()
const runtimeDir = "/test/runtime/dir"
testCases := []struct {
@@ -240,6 +244,7 @@ func TestUpdateV1Config(t *testing.T) {
require.NoError(t, err)
v1 := &containerd.ConfigV1{
Logger: logger,
Tree: config,
UseDefaultRuntimeName: true,
RuntimeType: runtimeType,
@@ -258,6 +263,7 @@ func TestUpdateV1Config(t *testing.T) {
}
func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
logger, _ := testlog.NewNullLogger()
const runtimeDir = "/test/runtime/dir"
testCases := []struct {
@@ -399,6 +405,7 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) {
require.NoError(t, err)
v1 := &containerd.ConfigV1{
Logger: logger,
Tree: config,
UseDefaultRuntimeName: true,
RuntimeType: runtimeType,

View File

@@ -21,6 +21,7 @@ import (
"testing"
"github.com/pelletier/go-toml"
testlog "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/require"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/config/engine/containerd"
@@ -32,6 +33,7 @@ const (
)
func TestUpdateV2ConfigDefaultRuntime(t *testing.T) {
logger, _ := testlog.NewNullLogger()
const runtimeDir = "/test/runtime/dir"
testCases := []struct {
@@ -76,6 +78,7 @@ func TestUpdateV2ConfigDefaultRuntime(t *testing.T) {
require.NoError(t, err)
v2 := &containerd.Config{
Logger: logger,
Tree: config,
RuntimeType: runtimeType,
}
@@ -90,6 +93,7 @@ func TestUpdateV2ConfigDefaultRuntime(t *testing.T) {
}
func TestUpdateV2Config(t *testing.T) {
logger, _ := testlog.NewNullLogger()
const runtimeDir = "/test/runtime/dir"
testCases := []struct {
@@ -200,8 +204,9 @@ func TestUpdateV2Config(t *testing.T) {
require.NoError(t, err)
v2 := &containerd.Config{
Logger: logger,
Tree: config,
RuntimeType: runtimeType,
RuntimeType: o.runtimeType,
ContainerAnnotations: []string{"cdi.k8s.io/*"},
}
@@ -218,6 +223,7 @@ func TestUpdateV2Config(t *testing.T) {
}
func TestUpdateV2ConfigWithRuncPresent(t *testing.T) {
logger, _ := testlog.NewNullLogger()
const runtimeDir = "/test/runtime/dir"
testCases := []struct {
@@ -353,6 +359,7 @@ func TestUpdateV2ConfigWithRuncPresent(t *testing.T) {
require.NoError(t, err)
v2 := &containerd.Config{
Logger: logger,
Tree: config,
RuntimeType: runtimeType,
ContainerAnnotations: []string{"cdi.k8s.io/*"},