-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_redis_cache
- Check if redis_configuration.aof_backup_enabled
configured
#22774
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xuzhang3. I think we can simplify the logic for setting aof_backup_enabled
but other than this should be good to go.
if strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | ||
output.AofBackupEnabled = utils.String(strconv.FormatBool(v.(bool))) | ||
} else if v.(bool) && !strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | ||
return nil, fmt.Errorf("The `aof_backup_enabled` property requires a `Premium` sku to be set") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified
if strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | |
output.AofBackupEnabled = utils.String(strconv.FormatBool(v.(bool))) | |
} else if v.(bool) && !strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | |
return nil, fmt.Errorf("The `aof_backup_enabled` property requires a `Premium` sku to be set") | |
} | |
if v.(bool) && !strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | |
return nil, fmt.Errorf("the `aof_backup_enabled` property requires a `Premium` sku to be set") | |
} | |
output.AofBackupEnabled = pointer.To(strconv.FormatBool(v.(bool))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the SKU is not "Premium", the default "false" will be sent to the service but this is not allowed by service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From your explanation it sounds like the only thing we need to check then is that the right sku is set?
if strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | |
output.AofBackupEnabled = utils.String(strconv.FormatBool(v.(bool))) | |
} else if v.(bool) && !strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | |
return nil, fmt.Errorf("The `aof_backup_enabled` property requires a `Premium` sku to be set") | |
} | |
if !strings.EqualFold(skuName, string(redis.SkuNamePremium)) { | |
return nil, fmt.Errorf("the `aof_backup_enabled` property requires a `Premium` sku to be set") | |
} | |
output.AofBackupEnabled = pointer.To(strconv.FormatBool(v.(bool))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the SKU check is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need block the request when the SKU is Premium
and aof_backup_enabled
configured and also need tohandle the default values scenario as the bool type will default sets to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need block the request when the SKU is
Premium
andaof_backup_enabled
configured
What is said here contradicts what's being done in this change.
I'm sorry but I'm not following anymore. Local testing isn't showing up any errors and the linked issue and PR have not given me any further insight.
Can you please add an acceptance test that demonstrates the problem this is trying to fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I will add the test to cover this scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is redis_configuration.aof_backup_enabled
is type bool. Even if not configured, the default value "false" will be set after creation.
Take one scenario for example:
- Create an Redis instance with SKU
Basic
- Update
maxmemory_policy
in theredis_configuration
. - Apply the Terraform command.
In step 3,redis_configuration.aof_backup_enabled
will get thefalse
value though if is not configured. AzureRM will send the request withredis_configuration.aof_backup_enabled=false
but service will reject the request becauseredis_configuration.aof_backup_enabled
can only be set when SKU isPremium
. So we need check t he SKU type and ignoreredis_configuration.aof_backup_enabled
if the SKU type is notPremium
Test TF:
resource "azurerm_redis_cache" "example" {
name = "xz3redistest"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
capacity = 1
family = "C"
sku_name = "Basic"
enable_non_ssl_port = false
redis_configuration {
# aof_backup_enabled = false
maxmemory_reserved = 125
maxmemory_delta = 125
maxmemory_policy = "allkeys-lru"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephybun Code updated and add a test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the acceptance test @xuzhang3. LGTM 🎉
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. |
Check if
aof_backup_enabled
configured.Relate PR: #22309 and issue #21967