Prevent a non-zero NanoCPUs from setting a zero CPU.Count

Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: b3649f4065984d16d2834b33f3f2d9f79c92603e
Component: engine
This commit is contained in:
Darren Stahl
2017-04-26 11:05:32 -07:00
parent 59446e4411
commit 037393eab4
+5
View File
@@ -92,6 +92,11 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
}
} else {
cpuPercent = uint8(c.HostConfig.NanoCPUs * 100 / int64(sysinfo.NumCPU()) / 1e9)
if cpuPercent < 1 {
// The requested NanoCPUs is so small that we rounded to 0, use 1 instead
cpuPercent = 1
}
}
}
memoryLimit := uint64(c.HostConfig.Memory)