BestEffort QoS class has min cpu shares

This commit is contained in:
Derek Carr 2017-02-17 01:01:27 -05:00
parent 5fb6b91faf
commit 9a1e30f776

View File

@ -282,16 +282,28 @@ func InitQOS(cgroupDriver, rootContainer string, subsystems *CgroupSubsystems) (
for _, qosClass := range qosClasses { for _, qosClass := range qosClasses {
// get the container's absolute name // get the container's absolute name
absoluteContainerName := CgroupName(path.Join(rootContainer, string(qosClass))) absoluteContainerName := CgroupName(path.Join(rootContainer, string(qosClass)))
resourceParameters := &ResourceConfig{}
// the BestEffort QoS class has a statically configured minShares value
if qosClass == v1.PodQOSBestEffort {
minShares := int64(MinShares)
resourceParameters.CpuShares = &minShares
}
// containerConfig object stores the cgroup specifications // containerConfig object stores the cgroup specifications
containerConfig := &CgroupConfig{ containerConfig := &CgroupConfig{
Name: absoluteContainerName, Name: absoluteContainerName,
ResourceParameters: &ResourceConfig{}, ResourceParameters: resourceParameters,
} }
// check if it exists // check if it exists
if !cm.Exists(absoluteContainerName) { if !cm.Exists(absoluteContainerName) {
if err := cm.Create(containerConfig); err != nil { if err := cm.Create(containerConfig); err != nil {
return QOSContainersInfo{}, fmt.Errorf("failed to create top level %v QOS cgroup : %v", qosClass, err) return QOSContainersInfo{}, fmt.Errorf("failed to create top level %v QOS cgroup : %v", qosClass, err)
} }
} else {
// to ensure we actually have the right state, we update the config on startup
if err := cm.Update(containerConfig); err != nil {
return QOSContainersInfo{}, fmt.Errorf("failed to update top level %v QOS cgroup : %v", qosClass, err)
}
} }
} }
// Store the top level qos container names // Store the top level qos container names