コード例 #1
0
func adjustCpuShares(version version.Version, hostConfig *runconfig.HostConfig) {
	if version.LessThan("1.19") {
		if hostConfig != nil && hostConfig.CpuShares > 0 {
			// Handle unsupported CpuShares
			if hostConfig.CpuShares < linuxMinCpuShares {
				logrus.Warnf("Changing requested CpuShares of %d to minimum allowed of %d", hostConfig.CpuShares, linuxMinCpuShares)
				hostConfig.CpuShares = linuxMinCpuShares
			} else if hostConfig.CpuShares > linuxMaxCpuShares {
				logrus.Warnf("Changing requested CpuShares of %d to maximum allowed of %d", hostConfig.CpuShares, linuxMaxCpuShares)
				hostConfig.CpuShares = linuxMaxCpuShares
			}
		}
	}
}