-
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_data_protection_backup_policy_postgresql
: support target_copy_setting
property
#24476
base: main
Are you sure you want to change the base?
azurerm_data_protection_backup_policy_postgresql
: support target_copy_setting
property
#24476
Conversation
} | ||
} else { | ||
// Add `life_cycle` in tf 4.0 since `retention_rule.#.life_cycle.#.target_copy_setting` and `retention_rule.#.life_cycle.#.data_store_type` should be specified by user and are not fixed. | ||
resource.Schema["retention_rule"].Elem.(*pluginsdk.Resource).Schema["life_cycle"] = &pluginsdk.Schema{ |
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.
Can multiple life_cycle
blocks be specified?
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
MaxItems: 1, | ||
Elem: &pluginsdk.Resource{ | ||
Schema: map[string]*pluginsdk.Schema{ | ||
"copy_after": { |
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.
What does this property do exactly?
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.
Specify when the backups are tiered across two or more selected data stores.
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.
that means this is a duration? should be call it copy_after_duration
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.
@katbyte thanks for your suggestion. copy_after
really does not make it clear what this feature means. I assume that copy_option
might be more suitable as the meaning of this feature is when
to back up across two of more selected data stores. For example: Setting Immediate Copy means having a backup copy in both the standard vault and the archive vault simultaneously. Setting Copy On Expiry means moving the backup to vault-archive upon its expiry in vault-standard. WDYT?
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 @sinbai - this looks like the new property won't take affect till 4.0?
is it possible to implement them now inline and support a graceful deprecation path for users instead of the hard breaking change in 4.0? as well allowing them to be used before?
Hi @katbyte thanks for your feedback and sounds like good suggestion. However, the newly added properties |
Changing something from optional -> required during a major version is just fine! so lets make it optional & enable people using these properties now with the 4.0 flag flipping it to how things should behave in 4.0 |
8d946c6
to
ed5ce33
Compare
Hi @katbyte thanks for your time and feedback. I have updated the code. Could you please take another look? Test results are as follows: |
|
||
--- | ||
|
||
A `target_copy_setting` block supports the following: |
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.
I think setting is redundant?
A `target_copy_setting` block supports the following: | |
A `target_copy` block supports the following: |
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.
Fixed.
|
||
A `target_copy_setting` block supports the following: | ||
|
||
* `copy_option` - (Required) Specifies when the backups are tiered across two or more selected data stores as a json encoded string. Changing this forces a new Backup Policy PostgreSQL to be created. |
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.
and this might be better as
* `copy_option` - (Required) Specifies when the backups are tiered across two or more selected data stores as a json encoded string. Changing this forces a new Backup Policy PostgreSQL to be created. | |
* `option_json` - (Required) Specifies when the backups are tiered across two or more selected data stores as a json encoded string. Changing this forces a new Backup Policy PostgreSQL to be created. |
?
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.
Fixed.
"default_retention_duration", | ||
"default_retention_rule.#", | ||
"default_retention_rule.0.%", | ||
"default_retention_rule.0.life_cycle.#", | ||
"default_retention_rule.0.life_cycle.0.%", | ||
"default_retention_rule.0.life_cycle.0.data_store_type", | ||
"default_retention_rule.0.life_cycle.0.duration", |
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.
are these not returned from the API? how come we are ignoring them?
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 API returns their values. However, TF supports both default_retention_duration
(deprecated in v4.0) and default_retention_rule
, which are two mutually exclusive properties in v3.0. These two properties corresponding to the same property of the API. Therefore, when importing resource in v3.0, I assume that we have no way of knowing whether the default_retention_duration
or default_retention_rule
is specified in the config, so I ignore them. Please see the following code in resourceDataProtectionBackupPolicyPostgreSQLRead func for details. Other than that, could you please let me know if there is a better solution?
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.
in the past when i have deprecated a property and replaced it with another property i've made them both computed and then just set them both in read so they have a valid property, and then only sent the value that exists/has been set in config off to the api in update/create.
is this possible with these fields to do that?
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.
Hi @katbyte thank you very much, I think this is a very good way. But there is a little problem. If the deprecated and replaced properties are set in read at the same time, then the following checks need to be deleted at the same time. Do you think it's okay to remove the check?
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.
Hi @katbyte a kind reminder in case you miss the above message.
Hi @katbyte I have updated the code to fix the comments above. The test results are as follows, could you please take another look? Thanks for your time. |
This PR is being labeled as "stale" because it has not been updated for 30 or more days. If this PR is still valid, please remove the "stale" label. If this PR is blocked, please add it to the "Blocked" milestone. If you need some help completing this PR, please leave a comment letting us know. Thank you! |
This PR is being labeled as "stale" because it has not been updated for 30 or more days. If this PR is still valid, please remove the "stale" label. If this PR is blocked, please add it to the "Blocked" milestone. If you need some help completing this PR, please leave a comment letting us know. Thank you! |
@sinbai having taken another look, this will require some significant rework before this can go in. Before we go down that path though I have a specific question which is: Has the request to add support for I ask because when creating a Backup Policy for PostgreSQL in the Portal, the option target copy setting isn't exposed at all and there is no way to set that information in the policy currently. See the JSON excerpt below of the Backup Policy created via the portal:
|
Hi @stephybun sorry for the late reply. Yes, support for |
44780ff
to
29ddef5
Compare
@sinbai as per discussed on tuesday here is the breaking change & deprecation guide that this PR should follow: https://github.com/hashicorp/terraform-provider-azurerm/commits/main/contributing/topics/guide-breaking-changes.md |
Hi @katbyte , thanks for your time. I'm assuming I've followed the breaking changes and deprecation guidelines for now, please let me know if I've missed/misunderstood something. Thank you! |
When supporting targetDataStoreCopySettings property, it was found that TF is currently hard-coded for default azure retention rule and source data store partial value for the lifecycles(Additionally, there is the fact that for the default Azure retention rules/Azure retention rule, the lifecycle may have multiple items instead of the current hard-coded single item). The service team has confirmed that these properties are not immutable. I assume that these properties should be specified by the user.
Therefore, while submitting this PR to support
targetDataStoreCopySettings
, the original implementation (dependency) was changed and some properties were opened to users.Test results: