MCPcopy Create free account
hub / github.com/containerd/cgroups / NewChild

Method NewChild

cgroup2/manager.go:375–400  ·  view source on GitHub ↗
(name string, resources *Resources)

Source from the content-addressed store, hash-verified

373}
374
375func (c *Manager) NewChild(name string, resources *Resources) (*Manager, error) {
376 if strings.HasPrefix(name, "/") {
377 return nil, errors.New("name must be relative")
378 }
379 path := filepath.Join(c.path, name)
380 if err := os.MkdirAll(path, defaultDirPerm); err != nil {
381 return nil, err
382 }
383 m := Manager{
384 unifiedMountpoint: c.unifiedMountpoint,
385 path: path,
386 }
387 if resources != nil {
388 if err := m.ToggleControllers(resources.EnabledControllers(), Enable); err != nil {
389 // clean up cgroup dir on failure
390 os.Remove(path)
391 return nil, err
392 }
393 }
394 if err := setResources(path, resources); err != nil {
395 // clean up cgroup dir on failure
396 os.Remove(path)
397 return nil, err
398 }
399 return &m, nil
400}
401
402func (c *Manager) AddProc(pid uint64) error {
403 v := Value{

Callers

nothing calls this directly

Calls 4

ToggleControllersMethod · 0.95
setResourcesFunction · 0.85
EnabledControllersMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected