Skip to content

Commit

Permalink
hcl: add new cores resources field
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Jul 26, 2021
1 parent 09903f4 commit a4e9c11
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions jobspec/parse_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ func parseResources(result *api.Resources, list *ast.ObjectList) error {
"memory_max",
"network",
"device",
"cores",
}
if err := checkHCLKeys(listVal, valid); err != nil {
return multierror.Prefix(err, "resources ->")
Expand Down
24 changes: 24 additions & 0 deletions jobspec/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,30 @@ func TestParse(t *testing.T) {
},
false,
},
{
"resources-cores.hcl",
&api.Job{
ID: stringToPtr("cores-test"),
Name: stringToPtr("cores-test"),
TaskGroups: []*api.TaskGroup{
{
Count: intToPtr(5),
Name: stringToPtr("group"),
Tasks: []*api.Task{
{
Name: "task",
Driver: "docker",
Resources: &api.Resources{
Cores: intToPtr(4),
MemoryMB: intToPtr(128),
},
},
},
},
},
},
false,
},
}

for _, tc := range cases {
Expand Down
14 changes: 14 additions & 0 deletions jobspec/test-fixtures/resources-cores.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
job "cores-test" {
group "group" {
count = 5

task "task" {
driver = "docker"

resources {
cores = 4
memory = 128
}
}
}
}

0 comments on commit a4e9c11

Please sign in to comment.