Преглед изворни кода

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

Signed-off-by: Darren Stahl <darst@microsoft.com>
Darren Stahl пре 8 година
родитељ
комит
b3649f4065
1 измењених фајлова са 5 додато и 0 уклоњено
  1. 5 0
      daemon/oci_windows.go

+ 5 - 0
daemon/oci_windows.go

@@ -92,6 +92,11 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
 			}
 			}
 		} else {
 		} else {
 			cpuPercent = uint8(c.HostConfig.NanoCPUs * 100 / int64(sysinfo.NumCPU()) / 1e9)
 			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)
 	memoryLimit := uint64(c.HostConfig.Memory)