Commit 50862f8e authored by Alex Dadgar's avatar Alex Dadgar
Browse files

Switch to using BlkioWeight

parent 095dc9ae
Showing with 15 additions and 12 deletions
+15 -12
......@@ -15,7 +15,7 @@ func TestCompose(t *testing.T) {
CPU: 1250,
MemoryMB: 1024,
DiskMB: 2048,
IOPS: 1024,
IOPS: 500,
Networks: []*NetworkResource{
&NetworkResource{
CIDR: "0.0.0.0/0",
......@@ -81,7 +81,7 @@ func TestCompose(t *testing.T) {
CPU: 1250,
MemoryMB: 1024,
DiskMB: 2048,
IOPS: 1024,
IOPS: 500,
Networks: []*NetworkResource{
&NetworkResource{
CIDR: "0.0.0.0/0",
......
......@@ -169,7 +169,7 @@ func TestTask_Require(t *testing.T) {
CPU: 1250,
MemoryMB: 128,
DiskMB: 2048,
IOPS: 1024,
IOPS: 500,
Networks: []*NetworkResource{
&NetworkResource{
CIDR: "0.0.0.0/0",
......
......@@ -87,7 +87,7 @@ func (e *LinuxExecutor) Limit(resources *structs.Resources) error {
}
if e.cgroupEnabled {
e.configureCgroups(resources)
return e.configureCgroups(resources)
}
return nil
......@@ -168,9 +168,9 @@ func (e *LinuxExecutor) cleanTaskDir() error {
return errs.ErrorOrNil()
}
func (e *LinuxExecutor) configureCgroups(resources *structs.Resources) {
func (e *LinuxExecutor) configureCgroups(resources *structs.Resources) error {
if !e.cgroupEnabled {
return
return nil
}
e.groups = &cgroupConfig.Cgroup{}
......@@ -204,13 +204,16 @@ func (e *LinuxExecutor) configureCgroups(resources *structs.Resources) {
e.groups.CpuShares = int64(resources.CPU)
}
if resources.IOPS > 0 {
throttleDevice := &cgroupConfig.ThrottleDevice{
Rate: uint64(resources.IOPS),
if resources.IOPS != 0 {
// Validate it is in an acceptable range.
if resources.IOPS < 10 || resources.IOPS > 1000 {
return fmt.Errorf("resources.IOPS must be between 10 and 1000: %d", resources.IOPS)
}
e.groups.BlkioThrottleReadIOPSDevice = append(e.groups.BlkioThrottleReadIOPSDevice, throttleDevice)
e.groups.BlkioThrottleWriteIOPSDevice = append(e.groups.BlkioThrottleWriteIOPSDevice, throttleDevice)
e.groups.BlkioWeight = uint16(resources.IOPS)
}
return nil
}
func (e *LinuxExecutor) runAs(userid string) error {
......
......@@ -187,7 +187,7 @@ The `resources` object supports the following keys:
* `disk` - The disk required in MB.
* `iops` - The number of IOPS required.
* `iops` - The number of IOPS required given as a weight between 10-1000.
* `memory` - The memory required in MB.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment