Skip to content

Commit

Permalink
Merge pull request #4970 from hashicorp/f-no-iops
Browse files Browse the repository at this point in the history
Deprecate IOPS
  • Loading branch information
dadgar authored Dec 11, 2018
2 parents 1678a84 + f555dc3 commit f42c060
Show file tree
Hide file tree
Showing 55 changed files with 73 additions and 253 deletions.
2 changes: 0 additions & 2 deletions api/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestCompose(t *testing.T) {
CPU: helper.IntToPtr(1250),
MemoryMB: helper.IntToPtr(1024),
DiskMB: helper.IntToPtr(2048),
IOPS: helper.IntToPtr(500),
Networks: []*NetworkResource{
{
CIDR: "0.0.0.0/0",
Expand Down Expand Up @@ -109,7 +108,6 @@ func TestCompose(t *testing.T) {
CPU: helper.IntToPtr(1250),
MemoryMB: helper.IntToPtr(1024),
DiskMB: helper.IntToPtr(2048),
IOPS: helper.IntToPtr(500),
Networks: []*NetworkResource{
{
CIDR: "0.0.0.0/0",
Expand Down
1 change: 0 additions & 1 deletion api/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ func TestJobs_Canonicalize(t *testing.T) {
Resources: &Resources{
CPU: helper.IntToPtr(500),
MemoryMB: helper.IntToPtr(256),
IOPS: helper.IntToPtr(0),
Networks: []*NetworkResource{
{
MBits: helper.IntToPtr(10),
Expand Down
15 changes: 6 additions & 9 deletions api/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ type Resources struct {
CPU *int
MemoryMB *int `mapstructure:"memory"`
DiskMB *int `mapstructure:"disk"`
IOPS *int
Networks []*NetworkResource
Devices []*RequestedDevice

// COMPAT(0.10)
// XXX Deprecated. Please do not use. The field will be removed in Nomad
// 0.10 and is only being kept to allow any references to be removed before
// then.
IOPS *int
}

// Canonicalize will supply missing values in the cases
Expand All @@ -23,9 +28,6 @@ func (r *Resources) Canonicalize() {
if r.MemoryMB == nil {
r.MemoryMB = defaultResources.MemoryMB
}
if r.IOPS == nil {
r.IOPS = defaultResources.IOPS
}
for _, n := range r.Networks {
n.Canonicalize()
}
Expand All @@ -42,7 +44,6 @@ func DefaultResources() *Resources {
return &Resources{
CPU: helper.IntToPtr(100),
MemoryMB: helper.IntToPtr(300),
IOPS: helper.IntToPtr(0),
}
}

Expand All @@ -55,7 +56,6 @@ func MinResources() *Resources {
return &Resources{
CPU: helper.IntToPtr(20),
MemoryMB: helper.IntToPtr(10),
IOPS: helper.IntToPtr(0),
}
}

Expand All @@ -73,9 +73,6 @@ func (r *Resources) Merge(other *Resources) {
if other.DiskMB != nil {
r.DiskMB = other.DiskMB
}
if other.IOPS != nil {
r.IOPS = other.IOPS
}
if len(other.Networks) != 0 {
r.Networks = other.Networks
}
Expand Down
1 change: 0 additions & 1 deletion api/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ func TestTask_Require(t *testing.T) {
CPU: helper.IntToPtr(1250),
MemoryMB: helper.IntToPtr(128),
DiskMB: helper.IntToPtr(2048),
IOPS: helper.IntToPtr(500),
Networks: []*NetworkResource{
{
CIDR: "0.0.0.0/0",
Expand Down
1 change: 0 additions & 1 deletion api/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func testJob() *Job {
Require(&Resources{
CPU: helper.IntToPtr(100),
MemoryMB: helper.IntToPtr(256),
IOPS: helper.IntToPtr(10),
}).
SetLogConfig(&LogConfig{
MaxFiles: helper.IntToPtr(1),
Expand Down
3 changes: 0 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,6 @@ func resourcesAreEqual(first, second *structs.Resources) bool {
if first.DiskMB != second.DiskMB {
return false
}
if first.IOPS != second.IOPS {
return false
}
if len(first.Networks) != len(second.Networks) {
return false
}
Expand Down
1 change: 0 additions & 1 deletion command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ func convertClientConfig(agentConfig *Config) (*clientconfig.Config, error) {
r.CPU = agentConfig.Client.Reserved.CPU
r.MemoryMB = agentConfig.Client.Reserved.MemoryMB
r.DiskMB = agentConfig.Client.Reserved.DiskMB
r.IOPS = agentConfig.Client.Reserved.IOPS

res := conf.Node.ReservedResources
if res == nil {
Expand Down
1 change: 0 additions & 1 deletion command/agent/config-test-fixtures/basic.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ client {
cpu = 10
memory = 10
disk = 10
iops = 10
reserved_ports = "1,100,10-12"
}
client_min_port = 1000
Expand Down
5 changes: 0 additions & 5 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"time"

"github.com/hashicorp/go-sockaddr/template"

client "github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad"
Expand Down Expand Up @@ -573,7 +572,6 @@ type Resources struct {
CPU int `mapstructure:"cpu"`
MemoryMB int `mapstructure:"memory"`
DiskMB int `mapstructure:"disk"`
IOPS int `mapstructure:"iops"`
ReservedPorts string `mapstructure:"reserved_ports"`
}

Expand Down Expand Up @@ -1394,9 +1392,6 @@ func (r *Resources) Merge(b *Resources) *Resources {
if b.DiskMB != 0 {
result.DiskMB = b.DiskMB
}
if b.IOPS != 0 {
result.IOPS = b.IOPS
}
if b.ReservedPorts != "" {
result.ReservedPorts = b.ReservedPorts
}
Expand Down
1 change: 0 additions & 1 deletion command/agent/config_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ func parseReserved(result **Resources, list *ast.ObjectList) error {
"cpu",
"memory",
"disk",
"iops",
"reserved_ports",
}
if err := helper.CheckHCLKeys(listVal, valid); err != nil {
Expand Down
1 change: 0 additions & 1 deletion command/agent/config_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func TestConfig_Parse(t *testing.T) {
CPU: 10,
MemoryMB: 10,
DiskMB: 10,
IOPS: 10,
ReservedPorts: "1,100,10-12",
},
GCInterval: 6 * time.Second,
Expand Down
2 changes: 0 additions & 2 deletions command/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func TestConfig_Merge(t *testing.T) {
CPU: 10,
MemoryMB: 10,
DiskMB: 10,
IOPS: 10,
ReservedPorts: "1,10-30,55",
},
},
Expand Down Expand Up @@ -254,7 +253,6 @@ func TestConfig_Merge(t *testing.T) {
CPU: 15,
MemoryMB: 15,
DiskMB: 15,
IOPS: 15,
ReservedPorts: "2,10-30,55",
},
GCInterval: 6 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion command/agent/job_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ func ApiResourcesToStructs(in *api.Resources) *structs.Resources {
out := &structs.Resources{
CPU: *in.CPU,
MemoryMB: *in.MemoryMB,
IOPS: *in.IOPS,
IOPS: *in.IOPS, // COMPAT(0.10): Only being used to issue warnings
}

if l := len(in.Networks); l != 0 {
Expand Down
6 changes: 2 additions & 4 deletions command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

humanize "github.com/dustin/go-humanize"

"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api/contexts"
"github.com/hashicorp/nomad/client/allocrunner/taskrunner/restarts"
Expand Down Expand Up @@ -490,7 +489,7 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str
}

var resourcesOutput []string
resourcesOutput = append(resourcesOutput, "CPU|Memory|Disk|IOPS|Addresses")
resourcesOutput = append(resourcesOutput, "CPU|Memory|Disk|Addresses")
firstAddr := ""
if len(addr) > 0 {
firstAddr = addr[0]
Expand All @@ -512,11 +511,10 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str
deviceStats = ru.ResourceUsage.DeviceStats
}
}
resourcesOutput = append(resourcesOutput, fmt.Sprintf("%v MHz|%v|%v|%v|%v",
resourcesOutput = append(resourcesOutput, fmt.Sprintf("%v MHz|%v|%v|%v",
cpuUsage,
memUsage,
humanize.IBytes(uint64(*alloc.Resources.DiskMB*bytesPerMegabyte)),
*resource.IOPS,
firstAddr))
for i := 1; i < len(addr); i++ {
resourcesOutput = append(resourcesOutput, fmt.Sprintf("||||%v", addr[i]))
Expand Down
15 changes: 5 additions & 10 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"time"

humanize "github.com/dustin/go-humanize"
"github.com/posener/complete"

"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api/contexts"
"github.com/hashicorp/nomad/helper"
"github.com/posener/complete"
)

const (
Expand Down Expand Up @@ -611,25 +610,22 @@ func getAllocatedResources(client *api.Client, runningAllocs []*api.Allocation,
total := computeNodeTotalResources(node)

// Get Resources
var cpu, mem, disk, iops int
var cpu, mem, disk int
for _, alloc := range runningAllocs {
cpu += *alloc.Resources.CPU
mem += *alloc.Resources.MemoryMB
disk += *alloc.Resources.DiskMB
iops += *alloc.Resources.IOPS
}

resources := make([]string, 2)
resources[0] = "CPU|Memory|Disk|IOPS"
resources[1] = fmt.Sprintf("%d/%d MHz|%s/%s|%s/%s|%d/%d",
resources[0] = "CPU|Memory|Disk"
resources[1] = fmt.Sprintf("%d/%d MHz|%s/%s|%s/%s",
cpu,
*total.CPU,
humanize.IBytes(uint64(mem*bytesPerMegabyte)),
humanize.IBytes(uint64(*total.MemoryMB*bytesPerMegabyte)),
humanize.IBytes(uint64(disk*bytesPerMegabyte)),
humanize.IBytes(uint64(*total.DiskMB*bytesPerMegabyte)),
iops,
*total.IOPS)
humanize.IBytes(uint64(*total.DiskMB*bytesPerMegabyte)))

return resources
}
Expand All @@ -647,7 +643,6 @@ func computeNodeTotalResources(node *api.Node) api.Resources {
total.CPU = helper.IntToPtr(*r.CPU - *res.CPU)
total.MemoryMB = helper.IntToPtr(*r.MemoryMB - *res.MemoryMB)
total.DiskMB = helper.IntToPtr(*r.DiskMB - *res.DiskMB)
total.IOPS = helper.IntToPtr(*r.IOPS - *res.IOPS)
return total
}

Expand Down
7 changes: 2 additions & 5 deletions drivers/shared/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import (
"time"

"github.com/armon/circbuf"
"github.com/hashicorp/consul-template/signals"
hclog "github.com/hashicorp/go-hclog"
multierror "github.com/hashicorp/go-multierror"

"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/lib/fifo"
"github.com/hashicorp/nomad/client/stats"
shelpers "github.com/hashicorp/nomad/helper/stats"

"github.com/hashicorp/consul-template/signals"
cstructs "github.com/hashicorp/nomad/client/structs"
shelpers "github.com/hashicorp/nomad/helper/stats"
)

const (
Expand Down Expand Up @@ -83,7 +81,6 @@ type Resources struct {
CPU int
MemoryMB int
DiskMB int
IOPS int
}

// ExecCommand holds the user command, args, and other isolation related
Expand Down
9 changes: 0 additions & 9 deletions drivers/shared/executor/executor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups"
cgroupFs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
lconfigs "github.com/opencontainers/runc/libcontainer/configs"

"github.com/syndtr/gocapability/capability"
)

Expand Down Expand Up @@ -559,14 +558,6 @@ func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error {
// Set the relative CPU shares for this cgroup.
cfg.Cgroups.Resources.CpuShares = uint64(command.Resources.CPU)

if command.Resources.IOPS != 0 {
// Validate it is in an acceptable range.
if command.Resources.IOPS < 10 || command.Resources.IOPS > 1000 {
return fmt.Errorf("resources.IOPS must be between 10 and 1000: %d", command.Resources.IOPS)
}

cfg.Cgroups.Resources.BlkioWeight = uint16(command.Resources.IOPS)
}
return nil
}

Expand Down
1 change: 0 additions & 1 deletion drivers/shared/executor/executor_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocD
Resources: &Resources{
CPU: task.Resources.CPU,
MemoryMB: task.Resources.MemoryMB,
IOPS: task.Resources.IOPS,
DiskMB: task.Resources.DiskMB,
},
}
Expand Down
4 changes: 1 addition & 3 deletions drivers/shared/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import (
"testing"
"time"

tu "github.com/hashicorp/nomad/testutil"

hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/nomad/client/allocdir"
cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/mock"
tu "github.com/hashicorp/nomad/testutil"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -54,7 +53,6 @@ func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) {
Resources: &Resources{
CPU: task.Resources.CPU,
MemoryMB: task.Resources.MemoryMB,
IOPS: task.Resources.IOPS,
DiskMB: task.Resources.DiskMB,
},
}
Expand Down
2 changes: 1 addition & 1 deletion jobspec/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ func parseResources(result *api.Resources, list *ast.ObjectList) error {
// Check for invalid keys
valid := []string{
"cpu",
"iops",
"iops", // COMPAT(0.10): Remove after one release to allow it to be removed from jobspecs
"disk",
"memory",
"network",
Expand Down
4 changes: 1 addition & 3 deletions jobspec/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"testing"
"time"

capi "github.com/hashicorp/consul/api"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/kr/pretty"

capi "github.com/hashicorp/consul/api"
)

func TestParse(t *testing.T) {
Expand Down Expand Up @@ -317,7 +316,6 @@ func TestParse(t *testing.T) {
Resources: &api.Resources{
CPU: helper.IntToPtr(500),
MemoryMB: helper.IntToPtr(128),
IOPS: helper.IntToPtr(30),
},
Constraints: []*api.Constraint{
{
Expand Down
1 change: 0 additions & 1 deletion jobspec/test-fixtures/basic.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ job "binstore-storagelocker" {
resources {
cpu = 500
memory = 128
iops = 30
}

constraint {
Expand Down
1 change: 0 additions & 1 deletion jobspec/test-fixtures/basic_wrong_key.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ job "binstore-storagelocker" {
resources {
cpu = 500
memory = 128
iops = 30
}

constraint {
Expand Down
Loading

0 comments on commit f42c060

Please sign in to comment.