Skip to content

Commit 93b1e8b

Browse files
Remove duplicated VGPU constants from controllers and use internal/consts package
Signed-off-by: Karthik Vetrivel <[email protected]>
1 parent c5d513d commit 93b1e8b

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

controllers/object_controls.go

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ const (
7777
TrustedCABundleMountDir = "/etc/pki/ca-trust/extracted/pem"
7878
// TrustedCACertificate indicates injected CA certificate name
7979
TrustedCACertificate = "tls-ca-bundle.pem"
80-
// VGPULicensingConfigMountPath indicates target mount path for vGPU licensing configuration file
81-
VGPULicensingConfigMountPath = "/drivers/gridd.conf"
82-
// VGPULicensingFileName is the vGPU licensing configuration filename
83-
VGPULicensingFileName = "gridd.conf"
84-
// NLSClientTokenMountPath inidicates the target mount path for NLS client config token file (.tok)
85-
NLSClientTokenMountPath = "/drivers/ClientConfigToken/client_configuration_token.tok"
86-
// NLSClientTokenFileName is the NLS client config token filename
87-
NLSClientTokenFileName = "client_configuration_token.tok"
88-
// VGPUTopologyConfigMountPath indicates target mount path for vGPU topology daemon configuration file
89-
VGPUTopologyConfigMountPath = "/etc/nvidia/nvidia-topologyd.conf"
90-
// VGPUTopologyConfigFileName is the vGPU topology daemon configuration filename
91-
VGPUTopologyConfigFileName = "nvidia-topologyd.conf"
9280
// DefaultRuntimeClass represents "nvidia" RuntimeClass
9381
DefaultRuntimeClass = "nvidia"
9482
// DriverInstallPathVolName represents volume name for driver install path provided to toolkit
@@ -3331,23 +3319,23 @@ func applyLicensingConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec
33313319
podSpec := &obj.Spec.Template.Spec
33323320

33333321
// add new volume mount
3334-
licensingConfigVolMount := corev1.VolumeMount{Name: "licensing-config", ReadOnly: true, MountPath: VGPULicensingConfigMountPath, SubPath: VGPULicensingFileName}
3322+
licensingConfigVolMount := corev1.VolumeMount{Name: "licensing-config", ReadOnly: true, MountPath: consts.VGPULicensingConfigMountPath, SubPath: consts.VGPULicensingFileName}
33353323
driverContainer.VolumeMounts = append(driverContainer.VolumeMounts, licensingConfigVolMount)
33363324

33373325
// gridd.conf always mounted
33383326
licenseItemsToInclude := []corev1.KeyToPath{
33393327
{
3340-
Key: VGPULicensingFileName,
3341-
Path: VGPULicensingFileName,
3328+
Key: consts.VGPULicensingFileName,
3329+
Path: consts.VGPULicensingFileName,
33423330
},
33433331
}
33443332
// client config token only mounted when NLS is enabled
33453333
if config.Driver.LicensingConfig.IsNLSEnabled() {
33463334
licenseItemsToInclude = append(licenseItemsToInclude, corev1.KeyToPath{
3347-
Key: NLSClientTokenFileName,
3348-
Path: NLSClientTokenFileName,
3335+
Key: consts.NLSClientTokenFileName,
3336+
Path: consts.NLSClientTokenFileName,
33493337
})
3350-
nlsTokenVolMount := corev1.VolumeMount{Name: "licensing-config", ReadOnly: true, MountPath: NLSClientTokenMountPath, SubPath: NLSClientTokenFileName}
3338+
nlsTokenVolMount := corev1.VolumeMount{Name: "licensing-config", ReadOnly: true, MountPath: consts.NLSClientTokenMountPath, SubPath: consts.NLSClientTokenFileName}
33513339
driverContainer.VolumeMounts = append(driverContainer.VolumeMounts, nlsTokenVolMount)
33523340
}
33533341

@@ -3448,7 +3436,7 @@ func transformDriverContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicy
34483436

34493437
// set virtual topology daemon configuration if specified for vGPU driver
34503438
if config.Driver.VirtualTopology != nil && config.Driver.VirtualTopology.Config != "" {
3451-
topologyConfigVolMount := corev1.VolumeMount{Name: "topology-config", ReadOnly: true, MountPath: VGPUTopologyConfigMountPath, SubPath: VGPUTopologyConfigFileName}
3439+
topologyConfigVolMount := corev1.VolumeMount{Name: "topology-config", ReadOnly: true, MountPath: consts.VGPUTopologyConfigMountPath, SubPath: consts.VGPUTopologyConfigFileName}
34523440
driverContainer.VolumeMounts = append(driverContainer.VolumeMounts, topologyConfigVolMount)
34533441

34543442
topologyConfigVolumeSource := corev1.VolumeSource{
@@ -3458,8 +3446,8 @@ func transformDriverContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicy
34583446
},
34593447
Items: []corev1.KeyToPath{
34603448
{
3461-
Key: VGPUTopologyConfigFileName,
3462-
Path: VGPUTopologyConfigFileName,
3449+
Key: consts.VGPUTopologyConfigFileName,
3450+
Path: consts.VGPUTopologyConfigFileName,
34633451
},
34643452
},
34653453
},

controllers/transforms_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3434

3535
gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1"
36+
"github.com/NVIDIA/gpu-operator/internal/consts"
3637
)
3738

3839
var mockClientMap map[string]client.Client
@@ -2910,8 +2911,8 @@ func TestTransformDriverWithLicensingConfig(t *testing.T) {
29102911
{
29112912
Name: "licensing-config",
29122913
ReadOnly: true,
2913-
MountPath: VGPULicensingConfigMountPath,
2914-
SubPath: VGPULicensingFileName,
2914+
MountPath: consts.VGPULicensingConfigMountPath,
2915+
SubPath: consts.VGPULicensingFileName,
29152916
},
29162917
},
29172918
}).WithInitContainer(corev1.Container{
@@ -2925,8 +2926,8 @@ func TestTransformDriverWithLicensingConfig(t *testing.T) {
29252926
SecretName: "test-secret",
29262927
Items: []corev1.KeyToPath{
29272928
{
2928-
Key: VGPULicensingFileName,
2929-
Path: VGPULicensingFileName,
2929+
Key: consts.VGPULicensingFileName,
2930+
Path: consts.VGPULicensingFileName,
29302931
},
29312932
},
29322933
},
@@ -2964,8 +2965,8 @@ func TestTransformDriverWithLicensingConfig(t *testing.T) {
29642965
{
29652966
Name: "licensing-config",
29662967
ReadOnly: true,
2967-
MountPath: VGPULicensingConfigMountPath,
2968-
SubPath: VGPULicensingFileName,
2968+
MountPath: consts.VGPULicensingConfigMountPath,
2969+
SubPath: consts.VGPULicensingFileName,
29692970
},
29702971
},
29712972
}).WithInitContainer(corev1.Container{
@@ -2981,8 +2982,8 @@ func TestTransformDriverWithLicensingConfig(t *testing.T) {
29812982
},
29822983
Items: []corev1.KeyToPath{
29832984
{
2984-
Key: VGPULicensingFileName,
2985-
Path: VGPULicensingFileName,
2985+
Key: consts.VGPULicensingFileName,
2986+
Path: consts.VGPULicensingFileName,
29862987
},
29872988
},
29882989
},

0 commit comments

Comments
 (0)