Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
cgroups: container: check cgroup path before use it
Browse files Browse the repository at this point in the history
The container CgroupsPath is optional acording to OCI.

If for some reason the runtime decide to not define one.
just skip cgroup operations.

This is going to be useful for upcoming, sandbox cgroup only
cgroup managment feature.

Signed-off-by: Jose Carlos Venegas Munoz <[email protected]>
  • Loading branch information
jcvenegas committed Aug 29, 2019
1 parent f45b2d9 commit 5a17d67
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,12 @@ func (c *Container) cgroupsCreate() (err error) {

// cgroupsDelete deletes the cgroups on the host for the associated container
func (c *Container) cgroupsDelete() error {

if c.state.CgroupPath == "" {
c.Logger().Debug("container does not have host cgroups: nothing to update")
return nil
}

cgroup, err := cgroupsLoadFunc(cgroups.V1,
cgroups.StaticPath(c.state.CgroupPath))

Expand Down Expand Up @@ -1506,6 +1512,11 @@ func (c *Container) cgroupsDelete() error {

// cgroupsUpdate updates cgroups on the host for the associated container
func (c *Container) cgroupsUpdate(resources specs.LinuxResources) error {

if c.state.CgroupPath == "" {
c.Logger().Debug("container does not have host cgroups: nothing to update")
return nil
}
cgroup, err := cgroupsLoadFunc(cgroups.V1,
cgroups.StaticPath(c.state.CgroupPath))
if err != nil {
Expand Down

0 comments on commit 5a17d67

Please sign in to comment.