hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.48k stars 4.56k forks source link

[Redis]: Updating redis instance with parameters (memory and notify_keyspace_events) in a single request fails #26026

Open gurubanigulati17 opened 2 months ago

gurubanigulati17 commented 2 months ago

Is there an existing issue for this?

Community Note

Terraform Version

0.15.5

AzureRM Provider Version

3.96.0

Affected Resource(s)/Data Source(s)

azurerm_redis_cache

Terraform Configuration Files

# redis.tf.json

{ 
   "resource": {
        "azurerm_redis_cache": {
            "redis_cache": {
                "name": "redis-42894ed2-15d8-44d2-8e74-a5602ad17a11",
                "location": "westeurope",
                "resource_group_name": "azure-staging-backing_services_infra",
                "redis_version": "6",
                "capacity": 3,
                "family": "P",
                "sku_name": "Premium",
                "enable_non_ssl_port": false,
                "minimum_tls_version": "1.2",
                "redis_configuration": {
                    "maxmemory_policy": "allkeys-lru",
                    "notify_keyspace_events": "AKE"
                },
                "patch_schedule": {
                    "day_of_week": "Saturday",
                    "start_hour_utc": 22,
                    "maintenance_window": "PT5H"
                },
                "shard_count": 2,
                "subnet_id": "xxx",
                "zones": [
                    "1",
                    "2",
                    "3"
                ],
                "timeouts": {
                    "create": "8h",
                    "update": "8h",
                    "delete": "8h"
                },
                "lifecycle": {
                    "prevent_destroy": true
                }
            }
        }
}

# terraform.tfstate

 {
      "mode": "managed",
      "type": "azurerm_redis_cache",
      "name": "redis_cache",
      "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
      "instances": [
        {
          "schema_version": 1,
          "attributes": {
            "capacity": 3,
            "enable_non_ssl_port": false,
            "family": "P",
            "redis_configuration": [
              {
                "active_directory_authentication_enabled": false,
                "aof_backup_enabled": false,
                "aof_storage_connection_string_0": "",
                "aof_storage_connection_string_1": "",
                "data_persistence_authentication_method": "SAS",
                "enable_authentication": true,
                "maxclients": 15000,
                "maxfragmentationmemory_reserved": 1330,
                "maxmemory_delta": 1330,
                "maxmemory_policy": "allkeys-lru",
                "maxmemory_reserved": 1330,
                "notify_keyspace_events": "AKE",
                "rdb_backup_enabled": false,
                "rdb_backup_frequency": 0,
                "rdb_backup_max_snapshot_count": 0,
                "rdb_storage_connection_string": "",
                "storage_account_subscription_id": ""
              }
            ],
            "redis_version": "6.0" }]
}

Debug Output/Panic Output

[ERROR] provider.terraform-provider-azurerm_v3.96.0_x5: Response contains error diagnostic: diagnostic_severity=ERROR diagnostic_summary="updating Redi (Subscription: "xxx"
Resource Group Name: "azure-staging-backing_services_infra"
Redis Name: "redis-42894ed2-15d8-44d2-8e74-a5602ad17a11"): unexpected status 400 with error: BadRequest: The following updates can't be processed in one single request, please send separate request to update them: 'properties.sku.capacity,properties.aadEnableDisable'.
RequestID=f2a51a49-38b1-40e3-bda0-8cc8dccd25b9" @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail= tf_proto_version=5.4 tf_provider_addr=provider tf_req_id=ceb6c5b7-c0f2-811b-c8a9-c65db4f4a983 tf_resource_type=azurerm_redis_cache tf_rpc=ApplyResourceChange timestamp=2024-05-19T18:46:09.807ZError: updating Redi (Subscription: "xxx"
Resource Group Name: "azure-staging-backing_services_infra"
Redis Name: "redis-42894ed2-15d8-44d2-8e74-a5602ad17a11"): unexpected status 400 with error: BadRequest: The following updates can't be processed in one single request, please send separate request to update them: 'properties.sku.capacity,properties.aadEnableDisable'.
RequestID=f2a51a49-38b1-40e3-bda0-8cc8dccd25b9  with azurerm_redis_cache.redis_cache,
  on redis.tf.json line 67, in resource.azurerm_redis_cache.redis_cache:

Expected Behaviour

The operation ought to proceed without the error message indicating, "The following updates can't be processed in one single request, please send separate request to update them: 'properties.sku.capacity,properties.aadEnableDisable". In versions 3.82.0 and below, this operation is supported. However, issues arise with versions beyond 3.82.0, wherein the operation fails. In addition, I have conducted tests on all the versions including 3.83.0, 3.84.0, 3.96.0, 3.97.0, 3.98.0, and 3.102.0.

Actual Behaviour

We attempted to trigger an update operation which increases the memory from 16 to 32 GB and changes notify_keyspace_events from AK to AKE in one call. However, it resulted in the failure of this update instance operation.

The error message received was 'The following updates can't be processed in one single request, please send separate request to update them: 'properties.sku.capacity,properties.aadEnableDisable'. This suggests that these changes should be requested separately.

Steps to Reproduce

  1. Setup a new Azure Redis Server with
    {
    "cluster_mode": true,
    "engine_version": "6.0",
    "eviction_policy": "allkeys-lru",
    "memory": 16,
    "multi_az": true,
    "notify_keyspace_events": "AK",
    "shard_count": 2
    }
  2. Change the memory to 32 and notify_keyspace_events to AKE.

Important Factoids

No response

References

No response

gurubanigulati17 commented 2 months ago

Any updates here !?

gurubanigulati17 commented 2 months ago

Any updates here !?

thoHeinze commented 2 months ago

@favoretti Sorry for pinging you directly, but I see you worked on two PRs related to enable AAD (which is mentioned in the error message above) in Redis: https://github.com/hashicorp/terraform-provider-azurerm/pull/23976 and https://github.com/hashicorp/terraform-provider-azurerm/pull/25006 Can you make any sense of the error described by @gurubanigulati17 ? Is this the new expected behaviour?

favoretti commented 2 months ago

@thoHeinze I see what is happening, but I don't know why. I'd need to run a couple of tests to try and reproduce it, but I'm unfortunately swamped hard at work right now, it will take me at least 2-3 weeks before I catch a breath to be able to do anything about this, sorry..