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

virtcontainers: inherit parent's CPU constraint #1530

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions virtcontainers/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ func (s *Sandbox) resources() (specs.LinuxResources, error) {
}

func (s *Sandbox) cpuResources() *specs.LinuxCPU {
// Use default period and quota if they are not specified.
// Container will inherit the constraints from its parent.
quota := int64(0)
period := uint64(0)
shares := uint64(0)
Expand Down Expand Up @@ -322,13 +324,6 @@ func (s *Sandbox) cpuResources() *specs.LinuxCPU {

cpu.Cpus = strings.Trim(cpu.Cpus, " \n\t,")

// use a default constraint for sandboxes without cpu constraints
if period == uint64(0) && quota == int64(0) {
// set a quota and period equal to the default number of vcpus
quota = int64(s.config.HypervisorConfig.NumVCPUs) * 100000
period = 100000
}

return validCPUResources(cpu)
}

Expand Down