func getCPUResources(config containertypes.Resources) *specs.CPU { cpu := specs.CPU{} if config.CPUShares != 0 { shares := uint64(config.CPUShares) cpu.Shares = &shares } if config.CpusetCpus != "" { cpuset := config.CpusetCpus cpu.Cpus = &cpuset } if config.CpusetMems != "" { cpuset := config.CpusetMems cpu.Mems = &cpuset } if config.NanoCPUs > 0 { // Use the default setting of 100ms, as is specified in: // https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt // cpu.cfs_period_us=100ms period := uint64(100 * time.Millisecond / time.Microsecond) quota := uint64(config.NanoCPUs) * period / 1e9 cpu.Period = &period cpu.Quota = "a } if config.CPUPeriod != 0 { period := uint64(config.CPUPeriod) cpu.Period = &period } if config.CPUQuota != 0 { quota := uint64(config.CPUQuota) cpu.Quota = "a } if config.CPURealtimePeriod != 0 { period := uint64(config.CPURealtimePeriod) cpu.RealtimePeriod = &period } if config.CPURealtimeRuntime != 0 { runtime := uint64(config.CPURealtimeRuntime) cpu.RealtimeRuntime = &runtime } return &cpu }
func getCPUResources(config containertypes.Resources) *specs.CPU { cpu := specs.CPU{} if config.CPUShares != 0 { shares := uint64(config.CPUShares) cpu.Shares = &shares } if config.CpusetCpus != "" { cpuset := config.CpusetCpus cpu.Cpus = &cpuset } if config.CpusetMems != "" { cpuset := config.CpusetMems cpu.Mems = &cpuset } if config.CPUPeriod != 0 { period := uint64(config.CPUPeriod) cpu.Period = &period } if config.CPUQuota != 0 { quota := uint64(config.CPUQuota) cpu.Quota = "a } if config.CPURealtimePeriod != 0 { period := uint64(config.CPURealtimePeriod) cpu.RealtimePeriod = &period } if config.CPURealtimeRuntime != 0 { runtime := uint64(config.CPURealtimeRuntime) cpu.RealtimeRuntime = &runtime } return &cpu }