diff --git a/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml b/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml index aa3077e31e..4377bec63d 100644 --- a/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml +++ b/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml @@ -307,6 +307,28 @@ tests: - name: S6_READ_ONLY_ROOT value: "1" + - it: should fail with non-unique nvidiaCaps + documentIndex: *deploymentDoc + set: + nvidiaCaps: + - compute + - compute + - utility + asserts: + - failedTemplate: + errorMessage: ([compute compute utility]) are must have unique values only + + - it: should fail with invalid nvidiaCaps value + documentIndex: *deploymentDoc + set: + nvidiaCaps: + - invalid + - compute + - utility + asserts: + - failedTemplate: + errorMessage: Invalid options in (invalid). Valid options are compute, utility, all, graphics, video + - it: should pass with envs defined with scaleGPU and custom capabilities documentIndex: *deploymentDoc set: diff --git a/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl b/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl index a2461fd0dc..892c155d68 100644 --- a/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl +++ b/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl @@ -12,6 +12,17 @@ will be parsed correctly without causing errors. {{- $nvidiaCaps := .nvidiaCaps -}} {{- $nvidiaCaps = $nvidiaCaps | default $root.Values.global.defaults.nvidiaCaps -}} + + {{- if not (deepEqual $nvidiaCaps (mustUniq $nvidiaCaps)) -}} + {{- fail (printf " (%s) are must have unique values only" $nvidiaCaps) -}} + {{- end -}} + + {{- range $cap := $nvidiaCaps -}} + {{- if not (mustHas $cap (list "compute" "utility" "all" "graphics" "video")) -}} + {{- fail (printf "Invalid options in (%s). Valid options are compute, utility, all, graphics, video" $cap) -}} + {{- end -}} + {{- end -}} + {{- $podSecCont := $root.Values.podSecurityContext -}} {{/* Calculate all security values */}}