@@ -36,8 +36,6 @@ import (
36
36
37
37
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
38
38
"k8s.io/apimachinery/pkg/util/sets"
39
- utilfeature "k8s.io/apiserver/pkg/util/feature"
40
- kubefeatures "k8s.io/kubernetes/pkg/features"
41
39
cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util"
42
40
"k8s.io/kubernetes/pkg/kubelet/metrics"
43
41
)
@@ -275,11 +273,8 @@ func (m *cgroupManagerImpl) Exists(name CgroupName) bool {
275
273
// scoped to the set control groups it understands. this is being discussed
276
274
// in https://github.com/opencontainers/runc/issues/1440
277
275
// once resolved, we can remove this code.
278
- whitelistControllers := sets .NewString ("cpu" , "cpuacct" , "cpuset" , "memory" , "systemd" )
276
+ whitelistControllers := sets .NewString ("cpu" , "cpuacct" , "cpuset" , "memory" , "systemd" , "pids" )
279
277
280
- if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportPodPidsLimit ) || utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportNodePidsLimit ) {
281
- whitelistControllers .Insert ("pids" )
282
- }
283
278
if _ , ok := m .subsystems .MountPoints ["hugetlb" ]; ok {
284
279
whitelistControllers .Insert ("hugetlb" )
285
280
}
@@ -352,13 +347,10 @@ func getSupportedSubsystems() map[subsystem]bool {
352
347
supportedSubsystems := map [subsystem ]bool {
353
348
& cgroupfs.MemoryGroup {}: true ,
354
349
& cgroupfs.CpuGroup {}: true ,
355
- & cgroupfs.PidsGroup {}: false ,
350
+ & cgroupfs.PidsGroup {}: true ,
356
351
}
357
352
// not all hosts support hugetlb cgroup, and in the absent of hugetlb, we will fail silently by reporting no capacity.
358
353
supportedSubsystems [& cgroupfs.HugetlbGroup {}] = false
359
- if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportPodPidsLimit ) || utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportNodePidsLimit ) {
360
- supportedSubsystems [& cgroupfs.PidsGroup {}] = true
361
- }
362
354
return supportedSubsystems
363
355
}
364
356
@@ -417,10 +409,7 @@ var (
417
409
// getSupportedUnifiedControllers returns a set of supported controllers when running on cgroup v2
418
410
func getSupportedUnifiedControllers () sets.String {
419
411
// This is the set of controllers used by the Kubelet
420
- supportedControllers := sets .NewString ("cpu" , "cpuset" , "memory" , "hugetlb" )
421
- if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportPodPidsLimit ) || utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportNodePidsLimit ) {
422
- supportedControllers .Insert ("pids" )
423
- }
412
+ supportedControllers := sets .NewString ("cpu" , "cpuset" , "memory" , "hugetlb" , "pids" )
424
413
// Memoize the set of controllers that are present in the root cgroup
425
414
availableRootControllersOnce .Do (func () {
426
415
var err error
@@ -547,10 +536,8 @@ func (m *cgroupManagerImpl) toResources(resourceConfig *ResourceConfig) *libcont
547
536
if resourceConfig .CpuPeriod != nil {
548
537
resources .CpuPeriod = * resourceConfig .CpuPeriod
549
538
}
550
- if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportPodPidsLimit ) || utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportNodePidsLimit ) {
551
- if resourceConfig .PidsLimit != nil {
552
- resources .PidsLimit = * resourceConfig .PidsLimit
553
- }
539
+ if resourceConfig .PidsLimit != nil {
540
+ resources .PidsLimit = * resourceConfig .PidsLimit
554
541
}
555
542
// if huge pages are enabled, we set them in libcontainer
556
543
// for each page size enumerated, set that value
@@ -608,7 +595,7 @@ func (m *cgroupManagerImpl) Update(cgroupConfig *CgroupConfig) error {
608
595
updateSystemdCgroupInfo (libcontainerCgroupConfig , cgroupConfig .Name )
609
596
}
610
597
611
- if utilfeature . DefaultFeatureGate . Enabled ( kubefeatures . SupportPodPidsLimit ) && cgroupConfig .ResourceParameters != nil && cgroupConfig .ResourceParameters .PidsLimit != nil {
598
+ if cgroupConfig .ResourceParameters != nil && cgroupConfig .ResourceParameters .PidsLimit != nil {
612
599
libcontainerCgroupConfig .PidsLimit = * cgroupConfig .ResourceParameters .PidsLimit
613
600
}
614
601
@@ -648,7 +635,7 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
648
635
}
649
636
}
650
637
651
- if utilfeature . DefaultFeatureGate . Enabled ( kubefeatures . SupportPodPidsLimit ) && cgroupConfig .ResourceParameters != nil && cgroupConfig .ResourceParameters .PidsLimit != nil {
638
+ if cgroupConfig .ResourceParameters != nil && cgroupConfig .ResourceParameters .PidsLimit != nil {
652
639
libcontainerCgroupConfig .PidsLimit = * cgroupConfig .ResourceParameters .PidsLimit
653
640
}
654
641
0 commit comments