MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / applyLicensingConfig

Function applyLicensingConfig

controllers/object_controls.go:3512–3556  ·  view source on GitHub ↗
(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, driverContainer *corev1.Container)

Source from the content-addressed store, hash-verified

3510}
3511
3512func applyLicensingConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, driverContainer *corev1.Container) {
3513 podSpec := &obj.Spec.Template.Spec
3514
3515 // add new volume mount
3516 licensingConfigVolMount := corev1.VolumeMount{Name: "licensing-config", ReadOnly: true, MountPath: consts.VGPULicensingConfigMountPath, SubPath: consts.VGPULicensingFileName}
3517 driverContainer.VolumeMounts = append(driverContainer.VolumeMounts, licensingConfigVolMount)
3518
3519 // gridd.conf always mounted
3520 licenseItemsToInclude := []corev1.KeyToPath{
3521 {
3522 Key: consts.VGPULicensingFileName,
3523 Path: consts.VGPULicensingFileName,
3524 },
3525 }
3526 // client config token only mounted when NLS is enabled
3527 if config.Driver.LicensingConfig.IsNLSEnabled() {
3528 licenseItemsToInclude = append(licenseItemsToInclude, corev1.KeyToPath{
3529 Key: consts.NLSClientTokenFileName,
3530 Path: consts.NLSClientTokenFileName,
3531 })
3532 nlsTokenVolMount := corev1.VolumeMount{Name: "licensing-config", ReadOnly: true, MountPath: consts.NLSClientTokenMountPath, SubPath: consts.NLSClientTokenFileName}
3533 driverContainer.VolumeMounts = append(driverContainer.VolumeMounts, nlsTokenVolMount)
3534 }
3535
3536 var licensingConfigVolumeSource corev1.VolumeSource
3537 if config.Driver.LicensingConfig.SecretName != "" {
3538 licensingConfigVolumeSource = corev1.VolumeSource{
3539 Secret: &corev1.SecretVolumeSource{
3540 SecretName: config.Driver.LicensingConfig.SecretName,
3541 Items: licenseItemsToInclude,
3542 },
3543 }
3544 } else if config.Driver.LicensingConfig.ConfigMapName != "" {
3545 licensingConfigVolumeSource = corev1.VolumeSource{
3546 ConfigMap: &corev1.ConfigMapVolumeSource{
3547 LocalObjectReference: corev1.LocalObjectReference{
3548 Name: config.Driver.LicensingConfig.ConfigMapName,
3549 },
3550 Items: licenseItemsToInclude,
3551 },
3552 }
3553 }
3554 licensingConfigVol := corev1.Volume{Name: "licensing-config", VolumeSource: licensingConfigVolumeSource}
3555 podSpec.Volumes = append(podSpec.Volumes, licensingConfigVol)
3556}
3557
3558func transformDriverContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error {
3559 podSpec := &obj.Spec.Template.Spec

Callers 1

transformDriverContainerFunction · 0.85

Calls 1

IsNLSEnabledMethod · 0.45

Tested by

no test coverage detected