Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max_tasks_per_node setting to Batch Pool #2805

Merged
merged 8 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions azurerm/data_source_batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func dataSourceArmBatchPool() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"max_tasks_per_node": {
Type: schema.TypeInt,
Computed: true,
},
"fixed_scale": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -191,6 +195,7 @@ func dataSourceArmBatchPoolRead(d *schema.ResourceData, meta interface{}) error

if props := resp.PoolProperties; props != nil {
d.Set("vm_size", props.VMSize)
d.Set("max_tasks_per_node", props.MaxTasksPerNode)

if scaleSettings := props.ScaleSettings; scaleSettings != nil {
if err := d.Set("auto_scale", azure.FlattenBatchPoolAutoScaleSettings(scaleSettings.AutoScale)); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions azurerm/data_source_batch_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestAccDataSourceAzureRMBatchPool_complete(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceName, "fixed_scale.0.resize_timeout", "PT15M"),
resource.TestCheckResourceAttr(dataSourceName, "fixed_scale.0.target_low_priority_nodes", "0"),
resource.TestCheckResourceAttr(dataSourceName, "node_agent_sku_id", "batch.node.ubuntu 16.04"),
resource.TestCheckResourceAttr(dataSourceName, "max_tasks_per_node", "2"),
resource.TestCheckResourceAttr(dataSourceName, "start_task.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "start_task.0.max_task_retry_count", "1"),
resource.TestCheckResourceAttr(dataSourceName, "start_task.0.environment.%", "1"),
Expand Down Expand Up @@ -85,6 +86,7 @@ resource "azurerm_batch_pool" "test" {
display_name = "Test Acc Pool"
vm_size = "Standard_A1"
node_agent_sku_id = "batch.node.ubuntu 16.04"
max_tasks_per_node = 2

fixed_scale {
target_dedicated_nodes = 2
Expand Down
12 changes: 10 additions & 2 deletions azurerm/resource_arm_batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func resourceArmBatchPool() *schema.Resource {
ForceNew: true,
DiffSuppressFunc: suppress.CaseDifference,
},
"max_tasks_per_node": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: validation.IntAtLeast(1),
},
"fixed_scale": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -243,6 +249,7 @@ func resourceArmBatchPoolCreate(d *schema.ResourceData, meta interface{}) error
poolName := d.Get("name").(string)
displayName := d.Get("display_name").(string)
vmSize := d.Get("vm_size").(string)
maxTasksPerNode := int32(d.Get("max_tasks_per_node").(int))

if requireResourcesToBeImported && d.IsNewResource() {
existing, err := client.Get(ctx, resourceGroup, accountName, poolName)
Expand All @@ -259,8 +266,9 @@ func resourceArmBatchPoolCreate(d *schema.ResourceData, meta interface{}) error

parameters := batch.Pool{
PoolProperties: &batch.PoolProperties{
VMSize: &vmSize,
DisplayName: &displayName,
VMSize: &vmSize,
DisplayName: &displayName,
MaxTasksPerNode: &maxTasksPerNode,
},
}

Expand Down
4 changes: 3 additions & 1 deletion azurerm/resource_arm_batch_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func TestAccAzureRMBatchPool_fixedScale_complete(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMBatchPoolExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "vm_size", "STANDARD_A1"),
resource.TestCheckResourceAttr(resourceName, "max_tasks_per_node", "2"),
resource.TestCheckResourceAttr(resourceName, "node_agent_sku_id", "batch.node.ubuntu 16.04"),
resource.TestCheckResourceAttr(resourceName, "account_name", fmt.Sprintf("testaccbatch%s", rs)),
resource.TestCheckResourceAttr(resourceName, "storage_image_reference.#", "1"),
Expand Down Expand Up @@ -323,7 +324,8 @@ resource "azurerm_batch_pool" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
account_name = "${azurerm_batch_account.test.name}"
display_name = "Test Acc Pool"
vm_size = "Standard_A1"
vm_size = "Standard_A1",
max_tasks_per_node = 2
node_agent_sku_id = "batch.node.ubuntu 16.04"

fixed_scale {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/batch_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The following attributes are exported:

* `start_task` - A `start_task` block that describes the start task settings for the Batch pool.

* `max_tasks_per_node` - The maximum number of tasks that can run concurrently on a single compute node in the pool.
metacpp marked this conversation as resolved.
Show resolved Hide resolved

---

A `fixed_scale` block exports the following:
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/batch_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ The following arguments are supported:

* `display_name` - (Optional) Specifies the display name of the Batch pool.

* `max_tasks_per_node` - (Optional) Specifies the maximum number of tasks that can run concurrently on a single compute node in the pool. Defaults to `1`.

* `fixed_scale` - (Optional) A `fixed_scale` block that describes the scale settings when using fixed scale.

* `auto_scale` - (Optional) A `auto_scale` block that describes the scale settings when using auto scale.
Expand Down