Skip to content

Commit f53991d

Browse files
committed
kube_features: DevicePluginCDIDevices: LockToDefault
1 parent 8cf93c8 commit f53991d

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

pkg/features/kube_features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
10061006

10071007
DisableNodeKubeProxyVersion: {Default: true, PreRelease: featuregate.Beta},
10081008

1009-
DevicePluginCDIDevices: {Default: true, PreRelease: featuregate.GA},
1009+
DevicePluginCDIDevices: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.33
10101010

10111011
DynamicResourceAllocation: {Default: false, PreRelease: featuregate.Alpha},
10121012

pkg/kubelet/cm/devicemanager/pod_devices_test.go

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ import (
2424
"github.com/stretchr/testify/require"
2525

2626
"k8s.io/apimachinery/pkg/util/sets"
27-
utilfeature "k8s.io/apiserver/pkg/util/feature"
28-
featuregatetesting "k8s.io/component-base/featuregate/testing"
2927
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
30-
"k8s.io/kubernetes/pkg/features"
3128
"k8s.io/kubernetes/pkg/kubelet/cm/devicemanager/checkpoint"
3229
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
3330
)
@@ -168,44 +165,18 @@ func TestDeviceRunContainerOptions(t *testing.T) {
168165
)
169166
testCases := []struct {
170167
description string
171-
gate bool
172168
responsesPerResource map[string]*pluginapi.ContainerAllocateResponse
173169
expected *DeviceRunContainerOptions
174170
}{
175171
{
176172
description: "empty response",
177-
gate: false,
178173
responsesPerResource: map[string]*pluginapi.ContainerAllocateResponse{
179174
resource1: newContainerAllocateResponse(),
180175
},
181176
expected: &DeviceRunContainerOptions{},
182177
},
183178
{
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",
209180
responsesPerResource: map[string]*pluginapi.ContainerAllocateResponse{
210181
resource1: newContainerAllocateResponse(
211182
withCDIDevices("vendor1.com/class1=device1", "vendor2.com/class2=device2"),
@@ -222,8 +193,7 @@ func TestDeviceRunContainerOptions(t *testing.T) {
222193
},
223194
},
224195
{
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",
227197
responsesPerResource: map[string]*pluginapi.ContainerAllocateResponse{
228198
resource1: newContainerAllocateResponse(
229199
withCDIDevices("vendor1.com/class1=device1", "vendor2.com/class2=device2"),
@@ -246,7 +216,6 @@ func TestDeviceRunContainerOptions(t *testing.T) {
246216
},
247217
{
248218
description: "duplicate cdi devices are skipped",
249-
gate: true,
250219
responsesPerResource: map[string]*pluginapi.ContainerAllocateResponse{
251220
resource1: newContainerAllocateResponse(
252221
withCDIDevices("vendor1.com/class1=device1", "vendor2.com/class2=device2"),
@@ -272,7 +241,6 @@ func TestDeviceRunContainerOptions(t *testing.T) {
272241
t.Run(tc.description, func(t *testing.T) {
273242
as := assert.New(t)
274243

275-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DevicePluginCDIDevices, tc.gate)
276244
podDevices := newPodDevices()
277245
for resourceName, response := range tc.responsesPerResource {
278246
podDevices.insert("pod", "container", resourceName,

0 commit comments

Comments
 (0)