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

enable_partitioning not supported servicebus Premium Sku. #1391

Merged
merged 3 commits into from
Jul 2, 2018
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
14 changes: 4 additions & 10 deletions azurerm/resource_arm_servicebus_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,9 @@ func resourceArmServiceBusQueueCreateUpdate(d *schema.ResourceData, meta interfa
// We need to retrieve the namespace because Premium namespace works differently from Basic and Standard,
// so it needs different rules applied to it.
namespacesClient := meta.(*ArmClient).serviceBusNamespacesClient
namespace, nsErr := namespacesClient.Get(ctx, resourceGroup, namespaceName)
if nsErr != nil {
return nsErr
}

// Enforce Premium namespace to have partitioning enabled in Terraform. It is always enabled in Azure for
// Premium SKU.
if namespace.Sku.Name == servicebus.Premium && !d.Get("enable_partitioning").(bool) {
return fmt.Errorf("ServiceBus Queue (%s) must have Partitioning enabled for Premium SKU", name)
namespace, err := namespacesClient.Get(ctx, resourceGroup, namespaceName)
if err != nil {
return fmt.Errorf("Error retrieving ServiceBus Namespace %q (Resource Group %q): %+v", resourceGroup, namespaceName, err)
}

// Enforce Premium namespace to have Express Entities disabled in Terraform since they are not supported for
Expand All @@ -178,7 +172,7 @@ func resourceArmServiceBusQueueCreateUpdate(d *schema.ResourceData, meta interfa
return fmt.Errorf("ServiceBus Queue (%s) does not support Express Entities in Premium SKU and must be disabled", name)
}

_, err := client.CreateOrUpdate(ctx, resourceGroup, namespaceName, name, parameters)
_, err = client.CreateOrUpdate(ctx, resourceGroup, namespaceName, name, parameters)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/resource_arm_servicebus_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestAccAzureRMServiceBusQueue_defaultEnablePartitioningPremium(t *testing.T
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusQueueExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "true"),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "false"),
resource.TestCheckResourceAttr(resourceName, "enable_express", "false"),
),
},
Expand Down Expand Up @@ -331,7 +331,7 @@ resource "azurerm_servicebus_queue" "test" {
name = "acctestservicebusqueue-%d"
resource_group_name = "${azurerm_resource_group.test.name}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
enable_partitioning = true
enable_partitioning = false
enable_express = false
}
`, rInt, location, rInt, rInt)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_servicebus_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func resourceArmServiceBusTopicRead(d *schema.ResourceData, meta interface{}) er

// if the topic is in a premium namespace and partitioning is enabled then the
// max size returned by the API will be 16 times greater than the value set
if *props.EnablePartitioning {
if partitioning := props.EnablePartitioning; partitioning != nil && *partitioning {
namespacesClient := meta.(*ArmClient).serviceBusNamespacesClient
namespace, err := namespacesClient.Get(ctx, resourceGroup, namespaceName)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions azurerm/resource_arm_servicebus_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestAccAzureRMServiceBusTopic_enablePartitioningPremium(t *testing.T) {
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "true"),
resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "false"),

This comment was marked as outdated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't possible due to the API behaviour change/limitation

resource.TestCheckResourceAttr(resourceName, "max_size_in_megabytes", "81920"),
),
},
Expand Down Expand Up @@ -349,7 +349,7 @@ resource "azurerm_servicebus_topic" "test" {
name = "acctestservicebustopic-%d"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
enable_partitioning = true
enable_partitioning = false
}
`, rInt, location, rInt, rInt)
}
Expand Down Expand Up @@ -397,7 +397,7 @@ resource "azurerm_servicebus_topic" "test" {
name = "acctestservicebustopic-%d"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
enable_partitioning = true
enable_partitioning = false
max_size_in_megabytes = 81920
}
`, rInt, location, rInt, rInt)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/servicebus_queue.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The following arguments are supported:
a new resource to be created. Defaults to `false` for Basic and Standard. For Premium, it MUST
be set to `true`.

~> **NOTE:** Service Bus Premium namespaces are always partitioned, so `enable_partitioning` MUST be set to `true`.
-> **NOTE:** Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. Please [see the documentation](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-partitioning) for more information.

* `lock_duration` - (Optional) The ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. Maximum value is 5 minutes. Defaults to 1 minute. (`PT1M`)

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/servicebus_topic.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ The following arguments are supported:
the topic to be partitioned across multiple message brokers. Defaults to false.
Changing this forces a new resource to be created.

-> **NOTE:** Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. Please [see the documentation](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-partitioning) for more information.

* `max_size_in_megabytes` - (Optional) Integer value which controls the size of
memory allocated for the topic. For supported values see the "Queue/topic size"
section of [this document](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-quotas).
Expand Down