Browse code

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

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2017/04/20 08:41:59
Showing 1 changed files
... ...
@@ -92,6 +92,11 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
92 92
 			}
93 93
 		} else {
94 94
 			cpuPercent = uint8(c.HostConfig.NanoCPUs * 100 / int64(sysinfo.NumCPU()) / 1e9)
95
+
96
+			if cpuPercent < 1 {
97
+				// The requested NanoCPUs is so small that we rounded to 0, use 1 instead
98
+				cpuPercent = 1
99
+			}
95 100
 		}
96 101
 	}
97 102
 	memoryLimit := uint64(c.HostConfig.Memory)