@@ -318,11 +318,7 @@ func (m *cgroupManagerImpl) Destroy(cgroupConfig *CgroupConfig) error {
318
318
if m .adapter .cgroupManagerType == libcontainerSystemd {
319
319
updateSystemdCgroupInfo (libcontainerCgroupConfig , cgroupConfig .Name )
320
320
} else {
321
- if libcontainercgroups .IsCgroup2UnifiedMode () {
322
- libcontainerCgroupConfig .Path = m .buildCgroupUnifiedPath (cgroupConfig .Name )
323
- } else {
324
- libcontainerCgroupConfig .Path = cgroupConfig .Name .ToCgroupfs ()
325
- }
321
+ libcontainerCgroupConfig .Path = cgroupConfig .Name .ToCgroupfs ()
326
322
}
327
323
328
324
manager , err := m .adapter .newManager (libcontainerCgroupConfig , cgroupPaths )
@@ -435,7 +431,7 @@ func getSupportedUnifiedControllers() sets.String {
435
431
436
432
// propagateControllers on an unified hierarchy enables all the supported controllers for the specified cgroup
437
433
func propagateControllers (path string ) error {
438
- if err := os .MkdirAll (path , 0755 ); err != nil {
434
+ if err := os .MkdirAll (filepath . Join ( cmutil . CgroupRoot , path ) , 0755 ); err != nil {
439
435
return fmt .Errorf ("failed to create cgroup %q : %v" , path , err )
440
436
}
441
437
@@ -464,15 +460,12 @@ func propagateControllers(path string) error {
464
460
}
465
461
466
462
current := cmutil .CgroupRoot
467
- relPath , err := filepath .Rel (cmutil .CgroupRoot , path )
468
- if err != nil {
469
- return fmt .Errorf ("failed to get relative path to cgroup root from %q: %v" , path , err )
470
- }
463
+
471
464
// Write the controllers list to each "cgroup.subtree_control" file until it reaches the parent cgroup.
472
465
// For the /foo/bar/baz cgroup, controllers must be enabled sequentially in the files:
473
466
// - /sys/fs/cgroup/foo/cgroup.subtree_control
474
467
// - /sys/fs/cgroup/foo/bar/cgroup.subtree_control
475
- for _ , p := range strings .Split (filepath .Dir (relPath ), "/" ) {
468
+ for _ , p := range strings .Split (filepath .Dir (path ), "/" ) {
476
469
current = filepath .Join (current , p )
477
470
if err := ioutil .WriteFile (filepath .Join (current , "cgroup.subtree_control" ), []byte (controllers ), 0755 ); err != nil {
478
471
return fmt .Errorf ("failed to enable controllers on %q: %v" , cmutil .CgroupRoot , err )
@@ -505,7 +498,7 @@ func setResourcesV2(cgroupConfig *libcontainerconfigs.Cgroup) error {
505
498
klog .V (6 ).Infof ("Optional subsystem not supported: hugetlb" )
506
499
}
507
500
508
- manager , err := cgroupfs2 .NewManager (cgroupConfig , cgroupConfig .Path , false )
501
+ manager , err := cgroupfs2 .NewManager (cgroupConfig , filepath . Join ( cmutil . CgroupRoot , cgroupConfig .Path ) , false )
509
502
if err != nil {
510
503
return fmt .Errorf ("failed to create cgroup v2 manager: %v" , err )
511
504
}
@@ -597,7 +590,7 @@ func (m *cgroupManagerImpl) Update(cgroupConfig *CgroupConfig) error {
597
590
598
591
unified := libcontainercgroups .IsCgroup2UnifiedMode ()
599
592
if unified {
600
- libcontainerCgroupConfig .Path = m . buildCgroupUnifiedPath ( cgroupConfig .Name )
593
+ libcontainerCgroupConfig .Path = cgroupConfig .Name . ToCgroupfs ( )
601
594
} else {
602
595
libcontainerCgroupConfig .Paths = m .buildCgroupPaths (cgroupConfig .Name )
603
596
}
@@ -641,11 +634,7 @@ func (m *cgroupManagerImpl) Create(cgroupConfig *CgroupConfig) error {
641
634
if m .adapter .cgroupManagerType == libcontainerSystemd {
642
635
updateSystemdCgroupInfo (libcontainerCgroupConfig , cgroupConfig .Name )
643
636
} else {
644
- if libcontainercgroups .IsCgroup2UnifiedMode () {
645
- libcontainerCgroupConfig .Path = m .buildCgroupUnifiedPath (cgroupConfig .Name )
646
- } else {
647
- libcontainerCgroupConfig .Path = cgroupConfig .Name .ToCgroupfs ()
648
- }
637
+ libcontainerCgroupConfig .Path = cgroupConfig .Name .ToCgroupfs ()
649
638
}
650
639
651
640
if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .SupportPodPidsLimit ) && cgroupConfig .ResourceParameters != nil && cgroupConfig .ResourceParameters .PidsLimit != nil {
0 commit comments