@@ -24,10 +24,7 @@ import (
24
24
"github.com/stretchr/testify/require"
25
25
26
26
"k8s.io/apimachinery/pkg/util/sets"
27
- utilfeature "k8s.io/apiserver/pkg/util/feature"
28
- featuregatetesting "k8s.io/component-base/featuregate/testing"
29
27
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
30
- "k8s.io/kubernetes/pkg/features"
31
28
"k8s.io/kubernetes/pkg/kubelet/cm/devicemanager/checkpoint"
32
29
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
33
30
)
@@ -168,44 +165,18 @@ func TestDeviceRunContainerOptions(t *testing.T) {
168
165
)
169
166
testCases := []struct {
170
167
description string
171
- gate bool
172
168
responsesPerResource map [string ]* pluginapi.ContainerAllocateResponse
173
169
expected * DeviceRunContainerOptions
174
170
}{
175
171
{
176
172
description : "empty response" ,
177
- gate : false ,
178
173
responsesPerResource : map [string ]* pluginapi.ContainerAllocateResponse {
179
174
resource1 : newContainerAllocateResponse (),
180
175
},
181
176
expected : & DeviceRunContainerOptions {},
182
177
},
183
178
{
184
- description : "cdi devices are ingored when feature gate is disabled" ,
185
- gate : false ,
186
- responsesPerResource : map [string ]* pluginapi.ContainerAllocateResponse {
187
- resource1 : newContainerAllocateResponse (
188
- withDevices (map [string ]string {"/dev/r1" : "/dev/r1" }),
189
- withMounts (map [string ]string {"/home/lib1" : "/home/lib1" }),
190
- withEnvs (map [string ]string {"ENV1" : "VALUE1" }),
191
- withCDIDevices ("vendor1.com/class1=device1" , "vendor2.com/class2=device2" ),
192
- ),
193
- },
194
- expected : & DeviceRunContainerOptions {
195
- Devices : []kubecontainer.DeviceInfo {
196
- {PathOnHost : "/dev/r1" , PathInContainer : "/dev/r1" , Permissions : "mrw" },
197
- },
198
- Mounts : []kubecontainer.Mount {
199
- {Name : "/home/lib1" , HostPath : "/home/lib1" , ContainerPath : "/home/lib1" , ReadOnly : true },
200
- },
201
- Envs : []kubecontainer.EnvVar {
202
- {Name : "ENV1" , Value : "VALUE1" },
203
- },
204
- },
205
- },
206
- {
207
- description : "cdi devices are handled when feature gate is enabled" ,
208
- gate : true ,
179
+ description : "cdi devices are handled" ,
209
180
responsesPerResource : map [string ]* pluginapi.ContainerAllocateResponse {
210
181
resource1 : newContainerAllocateResponse (
211
182
withCDIDevices ("vendor1.com/class1=device1" , "vendor2.com/class2=device2" ),
@@ -222,8 +193,7 @@ func TestDeviceRunContainerOptions(t *testing.T) {
222
193
},
223
194
},
224
195
{
225
- description : "cdi devices from multiple resources are handled when feature gate is enabled" ,
226
- gate : true ,
196
+ description : "cdi devices from multiple resources are handled" ,
227
197
responsesPerResource : map [string ]* pluginapi.ContainerAllocateResponse {
228
198
resource1 : newContainerAllocateResponse (
229
199
withCDIDevices ("vendor1.com/class1=device1" , "vendor2.com/class2=device2" ),
@@ -246,7 +216,6 @@ func TestDeviceRunContainerOptions(t *testing.T) {
246
216
},
247
217
{
248
218
description : "duplicate cdi devices are skipped" ,
249
- gate : true ,
250
219
responsesPerResource : map [string ]* pluginapi.ContainerAllocateResponse {
251
220
resource1 : newContainerAllocateResponse (
252
221
withCDIDevices ("vendor1.com/class1=device1" , "vendor2.com/class2=device2" ),
@@ -272,7 +241,6 @@ func TestDeviceRunContainerOptions(t *testing.T) {
272
241
t .Run (tc .description , func (t * testing.T ) {
273
242
as := assert .New (t )
274
243
275
- featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .DevicePluginCDIDevices , tc .gate )
276
244
podDevices := newPodDevices ()
277
245
for resourceName , response := range tc .responsesPerResource {
278
246
podDevices .insert ("pod" , "container" , resourceName ,
0 commit comments