Skip to content

Commit 4f378a9

Browse files
committed
[validation] error out when NRI Plugin is enabled and toolkit is disabled
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
1 parent e6cd031 commit 4f378a9

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

controllers/state_manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,5 +1151,10 @@ func validateClusterPolicySpec(spec *gpuv1.ClusterPolicySpec) error {
11511151
if !spec.CDI.IsEnabled() && spec.CDI.IsNRIPluginEnabled() {
11521152
return fmt.Errorf("the NRI Plugin cannot be enabled when CDI is disabled")
11531153
}
1154+
1155+
if spec.CDI.IsNRIPluginEnabled() && !spec.Toolkit.IsEnabled() {
1156+
return fmt.Errorf("the NRI Plugin cannot be enabled when the Container Toolkit is disabled")
1157+
}
1158+
11541159
return nil
11551160
}

controllers/state_manager_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ func TestValidateClusterPolicySpec(t *testing.T) {
318318
},
319319
err: errors.New("the NRI Plugin cannot be enabled when CDI is disabled"),
320320
},
321+
{
322+
description: "invalid CDI and Toolkit config combination",
323+
spec: &gpuv1.ClusterPolicySpec{
324+
CDI: gpuv1.CDIConfigSpec{
325+
Enabled: ptr.To(true),
326+
NRIPluginEnabled: ptr.To(true),
327+
},
328+
Toolkit: gpuv1.ToolkitSpec{
329+
Enabled: ptr.To(false),
330+
},
331+
},
332+
err: errors.New("the NRI Plugin cannot be enabled when the Container Toolkit is disabled"),
333+
},
321334
}
322335

323336
for _, tc := range tests {
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{{- if and (eq .Values.cdi.enabled false) (eq .Values.cdi.nriPluginEnabled true) }}
22
{{ fail "the NRI Plugin cannot be enabled when CDI is disabled" }}
3-
{{- end}}
3+
{{- end }}
4+
5+
{{- if and (eq .Values.cdi.nriPluginEnabled true) (eq .Values.toolkit.enabled false) }}
6+
{{ fail "the NRI Plugin cannot be enabled when the Container Toolkit is disabled" }}
7+
{{- end }}

0 commit comments

Comments
 (0)