@@ -32,9 +32,7 @@ import (
3232var (
3333 // ErrCgroupDeleted means the cgroup was deleted.
3434 ErrCgroupDeleted = errors .New ("cgroup deleted" )
35- // ErrCgroupV1Rootless means the cgroup v1 were attempted to be used in rootless environment.
36- ErrCgroupV1Rootless = errors .New ("no support for CGroups V1 in rootless environments" )
37- ErrStatCgroup = errors .New ("no cgroup available for gathering user statistics" )
35+ ErrStatCgroup = errors .New ("no cgroup available for gathering user statistics" )
3836
3937 isUnifiedOnce sync.Once
4038 isUnified bool
@@ -345,45 +343,17 @@ func NewSystemd(path string, resources *cgroups.Resources) (*CgroupControl, erro
345343
346344// Load loads an existing cgroup control.
347345func Load (path string ) (* CgroupControl , error ) {
348- cgroup2 , err := IsCgroup2UnifiedMode ()
346+ _ , err := IsCgroup2UnifiedMode ()
349347 if err != nil {
350348 return nil , err
351349 }
352350 control := & CgroupControl {
353- cgroup2 : cgroup2 ,
351+ cgroup2 : true ,
354352 systemd : false ,
355353 config : & cgroups.Cgroup {
356354 Path : path ,
357355 },
358356 }
359- if ! cgroup2 {
360- controllers , err := getAvailableControllers (handlers , false )
361- if err != nil {
362- return nil , err
363- }
364- control .additionalControllers = controllers
365- }
366- if ! cgroup2 {
367- oneExists := false
368- // check that the cgroup exists at least under one controller
369- for name := range handlers {
370- p := control .getCgroupv1Path (name )
371- if err := fileutils .Exists (p ); err == nil {
372- oneExists = true
373- break
374- }
375- }
376-
377- // if there is no controller at all, raise an error
378- if ! oneExists {
379- if unshare .IsRootless () {
380- return nil , ErrCgroupV1Rootless
381- }
382- // compatible with the error code
383- // used by containerd/cgroups
384- return nil , ErrCgroupDeleted
385- }
386- }
387357 return control , nil
388358}
389359
0 commit comments