mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-31 07:19:06 +00:00
cgroups: container: check cgroup path before use it
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 <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
parent
f45b2d9cc6
commit
5a17d671a4
@ -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))
|
||||
|
||||
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user