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

azurerm_servicebus_namespace - support for the premium_messaging_partitions property #24676

Merged
merged 12 commits into from
Feb 20, 2024

Conversation

xiaxyi
Copy link
Contributor

@xiaxyi xiaxyi commented Jan 29, 2024

part of the MS vanguard, the premium namespace is now support messaging partitions, add the feature to terraform as well.

acc tests:

--- PASS: TestAccAzureRMServiceBusNamespace_premiumCapacity (107.95s)
--- PASS: TestAccAzureRMServiceBusNamespace_premiumMessagingPartition (107.95s)

fix #24597

For the accepted value and the validation part, in theory, we shouldn't add 0 into the acceptable list because the feature only applies to servicebus premium namespace, not to the standard/ basic namespace, however, api will add 0 value for the standard/basic namespaces, as a result, we'll see diff like 0->null during the second apply.

For the default value, 0 is for the standard/basic namespace while 1 is for the premium namespace. we need to add the validation to check if users are trying to set 0 for the premium namespace, if they do, we throw error before the api does. Things are the same for the standard/ basic namespace, but we check the >0 value.

Product information: https://learn.microsoft.com/en-us/azure/service-bus-messaging/enable-partitions-premium

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Thanks @xiaxyi - There's some comments to take a look at below, as it appears there is some confusion about allowed values? Can you take a look?

@@ -51,6 +51,8 @@ The following arguments are supported:

* `capacity` - (Optional) Specifies the capacity. When `sku` is `Premium`, capacity can be `1`, `2`, `4`, `8` or `16`. When `sku` is `Basic` or `Standard`, capacity can be `0` only.

* `premium_messaging_partitions` - (Optional) Specifies the messaging partitions. When `sku` is `Premium`, messaging partitions can be `1`, `2`, `4`. When `sku` is `Basic` or `Standard`, messaging partitions can be `0` only. Changing this forces a new resource to be created.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* `premium_messaging_partitions` - (Optional) Specifies the messaging partitions. When `sku` is `Premium`, messaging partitions can be `1`, `2`, `4`. When `sku` is `Basic` or `Standard`, messaging partitions can be `0` only. Changing this forces a new resource to be created.
* `premium_messaging_partitions` - (Optional) Specifies the number of Premium Messaging Partitions. Only valid when `sku` is `Premium`. Possible values include `0`, `1`, `2`, and `4`. Defaults to `0`. Changing this forces a new resource to be created.

resource_group_name = azurerm_resource_group.test.name
sku = "Premium"
capacity = 2
premium_messaging_partitions = 0
Copy link
Member

Choose a reason for hiding this comment

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

This defaults to 0 so should be omitted here?

Suggested change
premium_messaging_partitions = 0

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.premiumMessagingPartition(data),
ExpectError: regexp.MustCompile("Service Bus SKU \"Premium\" only supports `premium_messaging_partitions` of 1, 2, 4"),
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match the schema validation above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validation error is for the premium namespaces

Comment on lines +351 to +353
if strings.EqualFold(sku, string(namespaces.SkuNamePremium)) && premiumMessagingUnit.(int) == 0 {
return fmt.Errorf("Service Bus SKU %q only supports `premium_messaging_partitions` of 1, 2, 4", sku)
}
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match the schema validation above? The property defaults to 0 also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for the premium namespace, 0 is not a valid value for premium namespace.

@xiaxyi
Copy link
Contributor Author

xiaxyi commented Jan 29, 2024

Thanks @jackofallops for reviewing this pr!

The feature is only available in service bus premium namespace but we still need to set it to 0 for the standard/ basic namespace

For premium namespace, the default value is 1, despite of the 0 value we put in the request body, like
image

@xiaxyi xiaxyi changed the title azurerm_servicebus_namespace - add premium_messaging_partitions for premium servicebus namespace azurerm_servicebus_namespace - support for the premium_messaging_partitions property Feb 4, 2024
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

We have some test fialures

------- Stdout: -------
=== RUN   TestAccAzureRMServiceBusNamespacePairing_basic
=== PAUSE TestAccAzureRMServiceBusNamespacePairing_basic
=== CONT  TestAccAzureRMServiceBusNamespacePairing_basic
    testcase.go:113: Step 1/2 error: Error running apply: exit status 1
        
        Error: Service Bus SKU "Premium" only supports `premium_messaging_partitions` of 1, 2, 4
        
          with azurerm_servicebus_namespace.primary_namespace_test,
          on terraform_plugin_test.tf line 31, in resource "azurerm_servicebus_namespace" "primary_namespace_test":
          31: resource "azurerm_servicebus_namespace" "primary_namespace_test" {
        
        
        Error: Service Bus SKU "Premium" only supports `premium_messaging_partitions` of 1, 2, 4
        
          with azurerm_servicebus_namespace.secondary_namespace_test,
          on terraform_plugin_test.tf line 39, in resource "azurerm_servicebus_namespace" "secondary_namespace_test":
          39: resource "azurerm_servicebus_namespace" "secondary_namespace_test" {
        
--- FAIL: TestAccAzureRMServiceBusNamespacePairing_basic (48.64s)
FAIL

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

can you please fix all failed test cases:

=== RUN   TestAccAzureRMServiceBusNamespace_networkRuleSet
=== PAUSE TestAccAzureRMServiceBusNamespace_networkRuleSet
=== CONT  TestAccAzureRMServiceBusNamespace_networkRuleSet
    testcase.go:113: Step 1/6 error: Error running apply: exit status 1
        
        Error: Service Bus SKU "Premium" only supports `premium_messaging_partitions` of 1, 2, 4
        
          with azurerm_servicebus_namespace.test,
          on terraform_plugin_test.tf line 43, in resource "azurerm_servicebus_namespace" "test":
          43: resource "azurerm_servicebus_namespace" "test" {
        
--- FAIL: TestAccAzureRMServiceBusNamespace_networkRuleSet (118.34s)
FAIL

------- Stdout: -------
=== RUN   TestAccServiceBusQueueAuthorizationRule_withAliasConnectionString
=== PAUSE TestAccServiceBusQueueAuthorizationRule_withAliasConnectionString
=== CONT  TestAccServiceBusQueueAuthorizationRule_withAliasConnectionString
    testcase.go:113: Step 1/3 error: Error running apply: exit status 1
        
        Error: Service Bus SKU "Premium" only supports `premium_messaging_partitions` of 1, 2, 4
        
          with azurerm_servicebus_namespace.primary_namespace_test,
          on terraform_plugin_test.tf line 31, in resource "azurerm_servicebus_namespace" "primary_namespace_test":
          31: resource "azurerm_servicebus_namespace" "primary_namespace_test" {
        
        
        Error: Service Bus SKU "Premium" only supports `premium_messaging_partitions` of 1, 2, 4
        
          with azurerm_servicebus_namespace.secondary_namespace_test,
          on terraform_plugin_test.tf line 44, in resource "azurerm_servicebus_namespace" "secondary_namespace_test":
          44: resource "azurerm_servicebus_namespace" "secondary_namespace_test" {
        
--- FAIL: TestAccServiceBusQueueAuthorizationRule_withAliasConnectionString (98.40s)
FAIL

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM ⛈️

@katbyte katbyte merged commit 939c063 into hashicorp:main Feb 20, 2024
33 checks passed
@github-actions github-actions bot added this to the v3.93.0 milestone Feb 20, 2024
katbyte added a commit that referenced this pull request Feb 20, 2024
rizkybiz pushed a commit to rizkybiz/terraform-provider-azurerm that referenced this pull request Feb 21, 2024
…artitions` property (hashicorp#24676)

* add premium messaging partition property

* â�fix test case

* change property value in test cases

* change docs and test cases based on reviewer

* update docs and test cases

* terrafmt

* update test case

* update test case for premium namespace

* update

* format test cases
rizkybiz pushed a commit to rizkybiz/terraform-provider-azurerm that referenced this pull request Feb 21, 2024
lemeurherve pushed a commit to jenkins-infra/azure that referenced this pull request Feb 23, 2024
<Actions>
<action
id="f410411e63aff4bb73a81c2aec1d373cf8a903e63b30dee2006b0030d8a94cc8">
        <h3>Bump Terraform `azurerm` provider version</h3>
<details
id="1d9343c012f5434ac9fe8a98135bae3667b399259be16d9b14302ea3bd424a24">
            <summary>Update Terraform lock file</summary>
<p>changes detected:&#xA;&#x9;&#34;hashicorp/azurerm&#34; updated from
&#34;3.92.0&#34; to &#34;3.93.0&#34; in file
&#34;.terraform.lock.hcl&#34;</p>
            <details>
                <summary>3.93.0</summary>
<pre>Changelog retrieved
from:&#xA;&#x9;https://github.com/hashicorp/terraform-provider-azurerm/releases/tag/v3.93.0&#xA;*
**New Data Source**: `azurerm_express_route_circuit_peering`
([#24971](https://github.com/hashicorp/terraform-provider-azurerm/issues/24971))&#xA;*
**New Data Source**: `azurerm_storage_table_entities`
([#24973](https://github.com/hashicorp/terraform-provider-azurerm/issues/24973))&#xA;*
**New Resource**: `azurerm_dev_center_catalog`
([#24833](https://github.com/hashicorp/terraform-provider-azurerm/issues/24833))&#xA;*
**New Resource**: `azurerm_system_center_virtual_machine_manager_server`
([#24278](https://github.com/hashicorp/terraform-provider-azurerm/issues/24278))&#xA;&#xA;BUG
FIXES:&#xA;&#xA;* `azurerm_key_vault` - conditionally polling the Data
Plane endpoint when `public_network_access_enabled` is set to false
([#23823](https://github.com/hashicorp/terraform-provider-azurerm/issues/23823))&#xA;*
`azurerm_storage_account` - allow the `identity.type` property to be
`SystemAssigned, UserAssigned` when using a Customer Managed Key
([#24923](https://github.com/hashicorp/terraform-provider-azurerm/issues/24923))&#xA;*
`azurerm_automation_account` - prevent the `identity.identity_ids` User
Assigned identity being set when not specified in config
([#24977](https://github.com/hashicorp/terraform-provider-azurerm/issues/24977))&#xA;&#xA;ENHANCEMENTS:&#xA;&#xA;*
dependencies: updating to `v0.20240221.1170458` of
`hashicorp/go-azure-sdk`
([#24967](https://github.com/hashicorp/terraform-provider-azurerm/issues/24967))&#xA;*
dependencies: refactor `azurerm_spring_cloud_configuration_service` to
use `go-azure-sdk`
([#24918](https://github.com/hashicorp/terraform-provider-azurerm/issues/24918))&#xA;*
provider: support or the feature flag
`virtual_machine_scale_set.reimage_on_manual_upgrade`
([#22975](https://github.com/hashicorp/terraform-provider-azurerm/issues/22975))&#xA;*
`sentinel`: updating to use the transport layer from
`hashicorp/go-azure-sdk` rather than `Azure/go-autorest`
([#24962](https://github.com/hashicorp/terraform-provider-azurerm/issues/24962))&#xA;*
`sqlvirtualmachines`: updating to use the transport layer from
`hashicorp/go-azure-sdk` rather than `Azure/go-autorest`
([#24912](https://github.com/hashicorp/terraform-provider-azurerm/issues/24912))&#xA;*
`nginx` : updating to use `2024-01-01-preview`
([#24868](https://github.com/hashicorp/terraform-provider-azurerm/issues/24868))&#xA;*
`azurerm_cosmosdb_account` - support for the `backup.tier` property
([#24595](https://github.com/hashicorp/terraform-provider-azurerm/issues/24595))&#xA;*
`azurerm_linux_virtual_machine` - the `virtual_machine_scale_set_id`
proeprty can now be changed without creating a new resource
([#24768](https://github.com/hashicorp/terraform-provider-azurerm/issues/24768))&#xA;*
`azurerm_machine_learning_workspace` - support for the
`managed_network.isolation_mode` property
([#24951](https://github.com/hashicorp/terraform-provider-azurerm/issues/24951))&#xA;*
`azurerm_private_dns_resolver_inbound_endpoint` - support the `static`
value for the `private_ip_allocation_method` property
([#24952](https://github.com/hashicorp/terraform-provider-azurerm/issues/24952))&#xA;*
`azurerm_postgresql_flexible_server` - expose the `storage_tier` field
([#24892](https://github.com/hashicorp/terraform-provider-azurerm/issues/24892))&#xA;*
`azurerm_redis_cache` - support for the
`preferred_data_persistence_auth_method` property
([#24370](https://github.com/hashicorp/terraform-provider-azurerm/issues/24370))&#xA;*
`azurerm_servicebus_namespace` - support for the
`premium_messaging_partitions` property
([#24676](https://github.com/hashicorp/terraform-provider-azurerm/issues/24676))&#xA;*
`azurerm_windows_virtual_machine` - the `virtual_machine_scale_set_id`
proeprty can now be changed without creating a new resource
([#24768](https://github.com/hashicorp/terraform-provider-azurerm/issues/24768))&#xA;&#xA;BUG
FIXES:&#xA;&#xA;* `azurerm_cognitive_deployment` - the
`version_upgrade_option` property can not be updated without creating a
new resource
([#24922](https://github.com/hashicorp/terraform-provider-azurerm/issues/24922))&#xA;*
`azurerm_data_protection_backup_vault` - support or the `soft_delete`
and `retention_duration_in_days` properties
([#24775](https://github.com/hashicorp/terraform-provider-azurerm/issues/24775))&#xA;*
`azurerm_data_factory_pipeline` - correctly handle incorrect header
values
([#24921](https://github.com/hashicorp/terraform-provider-azurerm/issues/24921))&#xA;*
`azurerm_kusto_cluster` - `optimized_auto_scale` is now updated after
`sku` has been updated
([#24906](https://github.com/hashicorp/terraform-provider-azurerm/issues/24906))&#xA;*
`azurerm_key_vault_certificate` - will now only update the
`lifetime_action` of the certificate block unless otherwise required
([#24755](https://github.com/hashicorp/terraform-provider-azurerm/issues/24755))&#xA;*
`azurerm_linux_virtual_machine_scale_set` - correctly include
`public_ip_prefix_id` during updates
([#24939](https://github.com/hashicorp/terraform-provider-azurerm/issues/24939))&#xA;*
`azurerm_postgresql_flexible_server` - the
`customer_managed_key.key_vault_key_id` property is now required
([#24981](https://github.com/hashicorp/terraform-provider-azurerm/issues/24981))&#xA;*
`azurerm_nginx_deployment` - changing the `sku` property now creates a
new resource
([#24905](https://github.com/hashicorp/terraform-provider-azurerm/issues/24905))&#xA;*
`azurerm_orchestrated_virtual_machine_scale_set` - the `disk_size_gb`
and `lun` parameters of `data_disks` are optional now
([#24944](https://github.com/hashicorp/terraform-provider-azurerm/issues/24944))&#xA;*
`azurerm_storage_account` - change order of API calls to be GET-then-PUT
ratehr then PATCHES
([#23935](https://github.com/hashicorp/terraform-provider-azurerm/issues/23935))&#xA;*
`azurerm_storage_account` - improve the validation around the
`immutability_policy` being used with `blob_properties`
([#24938](https://github.com/hashicorp/terraform-provider-azurerm/issues/24938))&#xA;*
`azurerm_security_center_setting` - prevent a bug when name is
`SENTINEL`
([#24497](https://github.com/hashicorp/terraform-provider-azurerm/issues/24497))&#xA;*
`azurerm_windows_virtual_machine_scale_set` - correctly include
`public_ip_prefix_id` during updates
([#24939](https://github.com/hashicorp/terraform-provider-azurerm/issues/24939))&#xA;&#xA;&#xA;&#xA;&#xA;</pre>
            </details>
        </details>
<a
href="https://infra.ci.jenkins.io/job/updatecli/job/azure/job/main/19/">Jenkins
pipeline link</a>
    </action>
</Actions>

---

<table>
  <tr>
    <td width="77">
<img src="https://www.updatecli.io/images/updatecli.png" alt="Updatecli
logo" width="50" height="50">
    </td>
    <td>
      <p>
Created automatically by <a
href="https://www.updatecli.io/">Updatecli</a>
      </p>
      <details><summary>Options:</summary>
        <br />
<p>Most of Updatecli configuration is done via <a
href="https://www.updatecli.io/docs/prologue/quick-start/">its
manifest(s)</a>.</p>
        <ul>
<li>If you close this pull request, Updatecli will automatically reopen
it, the next time it runs.</li>
<li>If you close this pull request and delete the base branch, Updatecli
will automatically recreate it, erasing all previous commits made.</li>
        </ul>
        <p>
Feel free to report any issues at <a
href="https://github.com/updatecli/updatecli/issues">github.com/updatecli/updatecli</a>.<br
/>
If you find this tool useful, do not hesitate to star <a
href="https://github.com/updatecli/updatecli/stargazers">our GitHub
repository</a> as a sign of appreciation, and/or to tell us directly on
our <a
href="https://matrix.to/#/#Updatecli_community:gitter.im">chat</a>!
        </p>
      </details>
    </td>
  </tr>
</table>

Co-authored-by: Jenkins Infra Bot (updatecli) <60776566+jenkins-infra-bot@users.noreply.github.com>
rizkybiz pushed a commit to rizkybiz/terraform-provider-azurerm that referenced this pull request Feb 29, 2024
…artitions` property (hashicorp#24676)

* add premium messaging partition property

* â�fix test case

* change property value in test cases

* change docs and test cases based on reviewer

* update docs and test cases

* terrafmt

* update test case

* update test case for premium namespace

* update

* format test cases
rizkybiz pushed a commit to rizkybiz/terraform-provider-azurerm that referenced this pull request Feb 29, 2024
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for multiple partitions in azurerm_servicebus_namespace
3 participants