-
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
Remove forceNew for zone
and standby_availability_zone
of azurerm_postgresql_flexible_server
#13507
Conversation
internal/services/postgres/postgresql_flexible_server_resource.go
Outdated
Show resolved
Hide resolved
internal/services/postgres/postgresql_flexible_server_resource.go
Outdated
Show resolved
Hide resolved
internal/services/postgres/postgresql_flexible_server_resource.go
Outdated
Show resolved
Hide resolved
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.
hey @neil-yechenwei
Thanks for this PR.
I've taken a look through and left a few comments inline - if we can fix those up then we should be able to take another look.
Thanks!
"zone": { | ||
Type: pluginsdk.TypeString, | ||
Optional: true, | ||
Computed: true, |
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 shouldn't be Computed, since we should highlight the change when this occurs/isn't specified:
Computed: true, |
Similarly, is there a reason this isn't Required? In other clouds it's the convention to have to specify a zone when creating resources
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.
TF would cause diff when it isn't specified. Because service backend would set it with random zone when it isn't specified in request body. So suggest to keep "Computed: true".
Service team confirmed generally user doesn't care where zone is. Service backend would optimize according to the actual situation and the success rate of the creation would be higher. So it isn't required property.
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.
@neil-yechenwei as above this needs to become un-computed here
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.
@tombuildsstuff , as service team confirmed user doesn't care where zone is, so I think we shouldn't highlight the change when it isn't specified. Does it make sense?
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.
@neil-yechenwei this is a core tenant of Terraform that we'll show you the drift - so this has to be uncomputed - I've opened #13843
"standby_availability_zone": { | ||
Type: pluginsdk.TypeString, | ||
Optional: true, | ||
Computed: true, |
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.
(same here)
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.
TF would cause diff when it isn't specified. Because service backend would set it with random zone when it isn't specified in request body. So suggest to keep "Computed: true".
Service team confirmed generally user doesn't care where standby_availability_zone is. Service backend would optimize according to the actual situation and the success rate of the creation would be higher. So it isn't required property.
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.
@neil-yechenwei as above this needs to become un-computed here
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.
as service team confirmed user doesn't care where zone is, so I think we shouldn't highlight the change when it isn't specified. Does it make sense?
@@ -626,8 +692,11 @@ func expandFlexibleServerHighAvailability(inputs []interface{}) *postgresqlflexi | |||
Mode: postgresqlflexibleservers.HighAvailabilityMode(input["mode"].(string)), | |||
} | |||
|
|||
if v, ok := input["standby_availability_zone"]; ok && v.(string) != "" { | |||
result.StandbyAvailabilityZone = utils.String(v.(string)) | |||
// service team confirmed it doesn't support to update `standby_availability_zone` after the PostgreSQL Flexible Server resource is 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.
so then how do users fail-back?
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.
Service team confirmed we shouldn't use update operation to fail-back. fail back should be implemented by restart with failover. For instance, zone is set to 1 and standby_availability_zone is set to 2 in tf config. Then we can failover zone to 2 and standby_availability_zone to 1 using restart with failover api after creation.
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.
@neil-yechenwei so in that scenario, how do users fail-back? e.g.
- Provision with
zone = 1
andstandby_zone = 2
- Failover so that
zone = 2
andstandby_zone = 1
- Failback so that
zone = 1
andstandby_zone = 2
(we should also probably rename this field to standby_zone
)
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.
Users need to keep zone=1
and standby_availability_zone=2
in TF config and run tf apply
to failback after automatically failover.
(standby_availability_zone
stands for healthy zone not unhealthy zone. So suggest to keep this name.)
@@ -91,7 +91,7 @@ The following arguments are supported: | |||
|
|||
* `administrator_password` - (Optional) The Password associated with the `administrator_login` for the PostgreSQL Flexible Server. Required when `create_mode` is `Default`. | |||
|
|||
* `zone` - (Optional) The availability zone of the PostgreSQL Flexible Server. Possible values are `1`, `2` and `3`. Changing this forces a new PostgreSQL Flexible Server to be created. | |||
* `zone` - (Optional) The availability zone of the PostgreSQL Flexible Server. Possible values are `1`, `2` and `3`. |
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 Availability Zones available change per-region - some support No Zones, some support 1 & 2, others support 1, 2 and 3. We should add a callout to explain this
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.
Updated
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("administrator_password", "create_mode"), |
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 we also add a step to fail-back here too?
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.
Updated
Thanks @tombuildsstuff , I've updated code. Please have another look. Thanks in advance. |
This functionality has been released in v2.82.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
…are no longer computed (#13843) es this comment #13507 (files) cc @neil-yechenwei
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. |
fixes #13443
Symptom:
Currently, TF would recreate this resource when
zone
andstandby_availability_zone
is changed.Expected behavior:
After confirmed with service team, TF shouldn't recreate this resource when
zone
andstandby_availability_zone
is changed, which means failover is triggered oncezone
andstandby_availability_zone
is changed and failover betweenzone
andstandby_availability_zone
is only supported when their values are exchanged.Failover is implemented by separate API not update API.
--- PASS: TestAccPostgresqlflexibleServer_basic (564.91s)
--- PASS: TestAccPostgresqlflexibleServer_requiresImport (598.20s)
--- PASS: TestAccPostgresqlflexibleServer_updateMaintenanceWindow (1090.05s)
--- PASS: TestAccPostgresqlflexibleServer_complete (1170.18s)
--- PASS: TestAccPostgresqlflexibleServer_updateSku (1490.18s)
--- PASS: TestAccPostgresqlflexibleServer_failover (1582.92s)
--- PASS: TestAccPostgresqlflexibleServer_pitr (1954.23s)
--- PASS: TestAccPostgresqlflexibleServer_completeUpdate (2148.29s)