Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions assets/state-driver/0500_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ spec:
mountPath: /run/mellanox/drivers
mountPropagation: HostToContainer
- name: sysfs-memory-online
mountPath: /sys/devices/system/memory/auto_online_blocks
mountPath: /sys/devices/system
- name: firmware-search-path
mountPath: /sys/module/firmware_class/parameters/path
- name: nv-firmware
Expand Down Expand Up @@ -322,7 +322,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
- name: sysfs-memory-online
hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
- name: nv-firmware
hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
50 changes: 50 additions & 0 deletions internal/state/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,56 @@ func TestDriverRenderMinimal(t *testing.T) {
require.Equal(t, string(o), actual)
}

func TestDriverSysfsMemoryOnlineVolumeUsesStableParentDirectory(t *testing.T) {
state, err := NewStateDriver(nil, "", nil, manifestDir)
require.Nil(t, err)
stateDriver, ok := state.(*stateDriver)
require.True(t, ok)

objs, err := stateDriver.renderer.RenderObjects(
&render.TemplatingData{
Data: getMinimalDriverRenderData(),
})
require.Nil(t, err)
require.NotEmpty(t, objs)

ds, err := getDaemonsetFromObjects(objs)
require.Nil(t, err)

var sysfsMemoryOnlineVolume *corev1.Volume
for i := range ds.Spec.Template.Spec.Volumes {
if ds.Spec.Template.Spec.Volumes[i].Name == "sysfs-memory-online" {
sysfsMemoryOnlineVolume = &ds.Spec.Template.Spec.Volumes[i]
break
}
}
require.NotNil(t, sysfsMemoryOnlineVolume)
require.NotNil(t, sysfsMemoryOnlineVolume.HostPath)
require.NotNil(t, sysfsMemoryOnlineVolume.HostPath.Type)
assert.Equal(t, "/sys/devices/system", sysfsMemoryOnlineVolume.HostPath.Path)
assert.Equal(t, corev1.HostPathDirectory, *sysfsMemoryOnlineVolume.HostPath.Type)

var driverContainer *corev1.Container
for i := range ds.Spec.Template.Spec.Containers {
if ds.Spec.Template.Spec.Containers[i].Name == "nvidia-driver-ctr" {
driverContainer = &ds.Spec.Template.Spec.Containers[i]
break
}
}
require.NotNil(t, driverContainer)

var sysfsMemoryOnlineMount *corev1.VolumeMount
for i := range driverContainer.VolumeMounts {
if driverContainer.VolumeMounts[i].Name == "sysfs-memory-online" {
sysfsMemoryOnlineMount = &driverContainer.VolumeMounts[i]
break
}
}
require.NotNil(t, sysfsMemoryOnlineMount)
assert.Equal(t, "/sys/devices/system", sysfsMemoryOnlineMount.MountPath)
assert.Empty(t, sysfsMemoryOnlineMount.SubPath)
}

func TestDriverHostNetwork(t *testing.T) {
const (
testName = "driver-hostnetwork"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -358,7 +358,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-full-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -381,7 +381,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -532,7 +532,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-gdrcopy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -412,7 +412,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-gds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -412,7 +412,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-hostnetwork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -351,7 +351,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -349,7 +349,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -468,7 +468,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-precompiled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -352,7 +352,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-rdma-hostmofed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -432,7 +432,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-rdma.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -426,7 +426,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-secret-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -444,7 +444,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -437,7 +437,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -343,7 +343,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -355,7 +355,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions internal/state/testdata/golden/driver-vgpu-licensing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ spec:
name: run-mellanox-drivers
- mountPath: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- mountPath: /sys/devices/system/memory/auto_online_blocks
- mountPath: /sys/devices/system
name: sysfs-memory-online
- mountPath: /lib/firmware
name: nv-firmware
Expand Down Expand Up @@ -355,7 +355,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
name: firmware-search-path
- hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
name: sysfs-memory-online
- hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
5 changes: 3 additions & 2 deletions manifests/state-driver/0500_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ spec:
- name: firmware-search-path
mountPath: /sys/module/firmware_class/parameters/path
- name: sysfs-memory-online
mountPath: /sys/devices/system/memory/auto_online_blocks
mountPath: /sys/devices/system
- name: nv-firmware
mountPath: /lib/firmware
- name: driver-startup-probe-script
Expand Down Expand Up @@ -689,7 +689,8 @@ spec:
path: /sys/module/firmware_class/parameters/path
- name: sysfs-memory-online
hostPath:
path: /sys/devices/system/memory/auto_online_blocks
path: /sys/devices/system
type: Directory
- name: nv-firmware
hostPath:
path: /run/nvidia/driver/lib/firmware
Expand Down
Loading