From fcd960e6bf0673a7f53e205b7faf843f31812601 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Tue, 29 Jan 2019 11:08:50 +0000 Subject: [PATCH 1/8] Add max_tasks_per_node setting --- azurerm/data_source_batch_pool.go | 5 +++++ azurerm/data_source_batch_pool_test.go | 2 ++ azurerm/resource_arm_batch_pool.go | 13 +++++++++++-- azurerm/resource_arm_batch_pool_test.go | 4 +++- website/docs/d/batch_pool.html.markdown | 2 ++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/azurerm/data_source_batch_pool.go b/azurerm/data_source_batch_pool.go index ac0dfef6dbca..32204d397570 100644 --- a/azurerm/data_source_batch_pool.go +++ b/azurerm/data_source_batch_pool.go @@ -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, @@ -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 { diff --git a/azurerm/data_source_batch_pool_test.go b/azurerm/data_source_batch_pool_test.go index 463902acce27..02a076da3c67 100644 --- a/azurerm/data_source_batch_pool_test.go +++ b/azurerm/data_source_batch_pool_test.go @@ -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"), @@ -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 diff --git a/azurerm/resource_arm_batch_pool.go b/azurerm/resource_arm_batch_pool.go index f600d771b16d..73164c058f20 100644 --- a/azurerm/resource_arm_batch_pool.go +++ b/azurerm/resource_arm_batch_pool.go @@ -55,6 +55,11 @@ func resourceArmBatchPool() *schema.Resource { ForceNew: true, DiffSuppressFunc: suppress.CaseDifference, }, + "max_tasks_per_node": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + }, "fixed_scale": { Type: schema.TypeList, Optional: true, @@ -243,6 +248,8 @@ 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 := d.Get("max_tasks_per_node").(int) + foo := int32(maxTasksPerNode) if requireResourcesToBeImported && d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, accountName, poolName) @@ -259,8 +266,10 @@ func resourceArmBatchPoolCreate(d *schema.ResourceData, meta interface{}) error parameters := batch.Pool{ PoolProperties: &batch.PoolProperties{ - VMSize: &vmSize, - DisplayName: &displayName, + VMSize: &vmSize, + DisplayName: &displayName, + MaxTasksPerNode: &foo, + // MaxTasksPerNode: &maxTasksPerNode, }, } diff --git a/azurerm/resource_arm_batch_pool_test.go b/azurerm/resource_arm_batch_pool_test.go index 44d006d5d1bc..5afda24e3e38 100644 --- a/azurerm/resource_arm_batch_pool_test.go +++ b/azurerm/resource_arm_batch_pool_test.go @@ -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"), @@ -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 { diff --git a/website/docs/d/batch_pool.html.markdown b/website/docs/d/batch_pool.html.markdown index b11461a0fe7b..8d3a40ce3d4c 100644 --- a/website/docs/d/batch_pool.html.markdown +++ b/website/docs/d/batch_pool.html.markdown @@ -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. + --- A `fixed_scale` block exports the following: From 532c35bfbe762f3a3249d5deb97c816acfad7c65 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 30 Jan 2019 16:30:32 +0000 Subject: [PATCH 2/8] Add resource doc change --- website/docs/r/batch_pool.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/r/batch_pool.html.markdown b/website/docs/r/batch_pool.html.markdown index 39c441c33ba0..605024cafa2f 100644 --- a/website/docs/r/batch_pool.html.markdown +++ b/website/docs/r/batch_pool.html.markdown @@ -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. + * `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. From 38e513c8a8be69ce8b556e2c9345077bdfcdb025 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 30 Jan 2019 16:32:15 +0000 Subject: [PATCH 3/8] Fixup temp variable name --- azurerm/resource_arm_batch_pool.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_batch_pool.go b/azurerm/resource_arm_batch_pool.go index 73164c058f20..c04997e689e7 100644 --- a/azurerm/resource_arm_batch_pool.go +++ b/azurerm/resource_arm_batch_pool.go @@ -249,7 +249,7 @@ func resourceArmBatchPoolCreate(d *schema.ResourceData, meta interface{}) error displayName := d.Get("display_name").(string) vmSize := d.Get("vm_size").(string) maxTasksPerNode := d.Get("max_tasks_per_node").(int) - foo := int32(maxTasksPerNode) + maxTasksPerNodeInt32 := int32(maxTasksPerNode) if requireResourcesToBeImported && d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, accountName, poolName) @@ -268,8 +268,7 @@ func resourceArmBatchPoolCreate(d *schema.ResourceData, meta interface{}) error PoolProperties: &batch.PoolProperties{ VMSize: &vmSize, DisplayName: &displayName, - MaxTasksPerNode: &foo, - // MaxTasksPerNode: &maxTasksPerNode, + MaxTasksPerNode: &maxTasksPerNodeInt32, }, } From 02c13ac39ec992196ff74c3597e0db27dddccaf4 Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 30 Jan 2019 16:48:03 +0000 Subject: [PATCH 4/8] Add validation to max_tasks_per_node --- azurerm/resource_arm_batch_pool.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_batch_pool.go b/azurerm/resource_arm_batch_pool.go index c04997e689e7..fd35a66e7ed4 100644 --- a/azurerm/resource_arm_batch_pool.go +++ b/azurerm/resource_arm_batch_pool.go @@ -56,9 +56,10 @@ func resourceArmBatchPool() *schema.Resource { DiffSuppressFunc: suppress.CaseDifference, }, "max_tasks_per_node": { - Type: schema.TypeInt, - Optional: true, - Default: 1, + Type: schema.TypeInt, + Optional: true, + Default: 1, + ValidateFunc: validation.IntAtLeast(1), }, "fixed_scale": { Type: schema.TypeList, From c858a908c19908c8a88303cd58b28957c353791b Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 30 Jan 2019 16:48:23 +0000 Subject: [PATCH 5/8] Remove temp int32 variable --- azurerm/resource_arm_batch_pool.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azurerm/resource_arm_batch_pool.go b/azurerm/resource_arm_batch_pool.go index fd35a66e7ed4..42d3f8038ddf 100644 --- a/azurerm/resource_arm_batch_pool.go +++ b/azurerm/resource_arm_batch_pool.go @@ -249,8 +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 := d.Get("max_tasks_per_node").(int) - maxTasksPerNodeInt32 := int32(maxTasksPerNode) + maxTasksPerNode := int32(d.Get("max_tasks_per_node").(int)) if requireResourcesToBeImported && d.IsNewResource() { existing, err := client.Get(ctx, resourceGroup, accountName, poolName) @@ -269,7 +268,7 @@ func resourceArmBatchPoolCreate(d *schema.ResourceData, meta interface{}) error PoolProperties: &batch.PoolProperties{ VMSize: &vmSize, DisplayName: &displayName, - MaxTasksPerNode: &maxTasksPerNodeInt32, + MaxTasksPerNode: &maxTasksPerNode, }, } From 09336b1394fcba64630e133cb9a2a2f3b62cb0ab Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 30 Jan 2019 17:54:36 +0000 Subject: [PATCH 6/8] Fix formatting --- azurerm/resource_arm_batch_pool_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/resource_arm_batch_pool_test.go b/azurerm/resource_arm_batch_pool_test.go index 5afda24e3e38..80123e45e412 100644 --- a/azurerm/resource_arm_batch_pool_test.go +++ b/azurerm/resource_arm_batch_pool_test.go @@ -324,8 +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", - max_tasks_per_node = 2 + vm_size = "Standard_A1", + max_tasks_per_node = 2 node_agent_sku_id = "batch.node.ubuntu 16.04" fixed_scale { From 70a0d61b70a885642acf09dfeb3125bdd3d0c23f Mon Sep 17 00:00:00 2001 From: Stuart Leeks Date: Wed, 30 Jan 2019 17:56:13 +0000 Subject: [PATCH 7/8] Add default value to docs --- website/docs/d/batch_pool.html.markdown | 2 +- website/docs/r/batch_pool.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/batch_pool.html.markdown b/website/docs/d/batch_pool.html.markdown index 8d3a40ce3d4c..d094362373f1 100644 --- a/website/docs/d/batch_pool.html.markdown +++ b/website/docs/d/batch_pool.html.markdown @@ -43,7 +43,7 @@ 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. +* `max_tasks_per_node` - The maximum number of tasks that can run concurrently on a single compute node in the pool. Defaults to `1`. --- diff --git a/website/docs/r/batch_pool.html.markdown b/website/docs/r/batch_pool.html.markdown index 605024cafa2f..aec085ecdc54 100644 --- a/website/docs/r/batch_pool.html.markdown +++ b/website/docs/r/batch_pool.html.markdown @@ -102,7 +102,7 @@ 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. +* `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. From c28c28528a16b496638c63573ff89ed1d7ec707b Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 30 Jan 2019 22:35:03 +0000 Subject: [PATCH 8/8] Remove unnecessary defay Co-Authored-By: stuartleeks --- website/docs/d/batch_pool.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/d/batch_pool.html.markdown b/website/docs/d/batch_pool.html.markdown index d094362373f1..8d3a40ce3d4c 100644 --- a/website/docs/d/batch_pool.html.markdown +++ b/website/docs/d/batch_pool.html.markdown @@ -43,7 +43,7 @@ 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. Defaults to `1`. +* `max_tasks_per_node` - The maximum number of tasks that can run concurrently on a single compute node in the pool. ---