-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Change authorized_networks field in sql instance to be a Set. #564
Conversation
=== RUN TestAccGoogleSqlDatabaseInstance_importBasic
--- PASS: TestAccGoogleSqlDatabaseInstance_importBasic (50.46s)
=== RUN TestAccGoogleSqlDatabaseInstance_importBasic3
--- PASS: TestAccGoogleSqlDatabaseInstance_importBasic3 (372.75s)
=== RUN TestAccGoogleSqlDatabaseInstance_basic
--- PASS: TestAccGoogleSqlDatabaseInstance_basic (61.45s)
=== RUN TestAccGoogleSqlDatabaseInstance_basic2
--- PASS: TestAccGoogleSqlDatabaseInstance_basic2 (60.20s)
=== RUN TestAccGoogleSqlDatabaseInstance_basic3
--- PASS: TestAccGoogleSqlDatabaseInstance_basic3 (352.58s)
=== RUN TestAccGoogleSqlDatabaseInstance_dontDeleteDefaultUserOnReplica
--- PASS: TestAccGoogleSqlDatabaseInstance_dontDeleteDefaultUserOnReplica (694.33s)
=== RUN TestAccGoogleSqlDatabaseInstance_settings_basic
--- PASS: TestAccGoogleSqlDatabaseInstance_settings_basic (55.86s)
=== RUN TestAccGoogleSqlDatabaseInstance_slave
--- PASS: TestAccGoogleSqlDatabaseInstance_slave (1011.91s)
=== RUN TestAccGoogleSqlDatabaseInstance_maintenance
--- PASS: TestAccGoogleSqlDatabaseInstance_maintenance (452.63s)
=== RUN TestAccGoogleSqlDatabaseInstance_diskspecs
--- PASS: TestAccGoogleSqlDatabaseInstance_diskspecs (463.82s)
=== RUN TestAccGoogleSqlDatabaseInstance_settings_upgrade
--- PASS: TestAccGoogleSqlDatabaseInstance_settings_upgrade (67.96s)
=== RUN TestAccGoogleSqlDatabaseInstance_multipleOperations
--- PASS: TestAccGoogleSqlDatabaseInstance_multipleOperations (85.39s)
=== RUN TestAccGoogleSqlDatabaseInstance_authNets
--- PASS: TestAccGoogleSqlDatabaseInstance_authNets (62.45s)
=== RUN TestAccGoogleSqlDatabaseInstance_settings_downgrade
--- PASS: TestAccGoogleSqlDatabaseInstance_settings_downgrade (45.33s) |
Since you're changing it from a List to a Set, you'll also need to add a state migration for people who already have |
You actually don't need to. The read method is always called prior to do an |
for _, authNetworkConfig := range configured.List() { | ||
entry := authNetworkConfig.(map[string]interface{}) | ||
|
||
entries = append(entries, &sqladmin.AclEntry{ |
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.
If this resource were ForceNew I think this (putting everything in the struct instead of checking if it's set first) would work, but since it's updatable you'll need ForceSendFields
in order to be able to change values from non-empty to empty. But then by supplying ForceSendFields
, you're insisting that each value has a default of empty, and I haven't checked whether that's actually true. If it is, can you add a comment as to why this is ok? (likewise with expandIpConfiguration
)
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.
Ok the actual more important comment I meant to make here: If any of these aren't set this will panic because you can't type-assert nil to a string.
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.
Actually, check me on that. I'm not sure whether it'll be nil or the zero value.
From the looks of it--please correct me if I'm wrong--this appears to be a breaking change.
|
|
For 2, the breaking change is we're changing the semantics of the command; whereas before it was "I will ensure this subset of resources exist", it would now be "I will ensure these and only these resources exist". For users with version ranges set, that's an unexpected and destructive upgrade experience that may not be intentionally opted into. (Unless I'm misreading this code, which is entirely possible.) |
Ah ok, I see it now. So the issue is if they had a config with |
I think it would work out that if you had a config with A, B, and C, and the API had A, B, C, and D, before the update Terraform would think this is fine and not do anything. After the update, even if the config isn't modified at all, plan would still show it's going to drop D, because D would now be added to the state? Maybe? Now I'm not sure, because that should've broken with Read being fixed. I'll have to take a closer look at the code. |
Oh right. Hmm. For that one specifically we didn't do it in a major release. We did add release notes, though for some reason it doesn't seem to have actually included all the fields that were changed: https://github.com/terraform-providers/terraform-provider-google/blob/master/CHANGELOG.md#012-july-20-2017 |
Hm. Well, from what I can see, Update's behaviour will definitely change, because it used to merge the list of authorized_networks from the API and the list of authorized_networks in the config, then just create new networks from the config not found in the API--but it would never remove an authorized_network from the API if it wasn't found in the config. And now that behaviour is being corrected, I believe. As for the 0.1.2 release, that was OK because semver explicitly states that anything is fair game before 1.0.0--there is no meaning, and breaking changes can happen pretty much any time. But now that we hit 1.0.0, a breaking change should bump us to 2.0.0, because users have the expectation that a 1.X.0 release will just contain new features and bug fixes, and 1.1.Y release will just contain bug fixes, and they should be safe to upgrade to without any user interaction. |
So something we could do if we're not ready for a major release yet would just be to break this apart into two separate changes- one to make it a set (in order to fix the linked issue), and the other to simplify the logic. |
I can definitely split the change in two. @paddycarver, do you agree with this course of action? |
I'm game 👍 I'm cool with the access-by-index being broken because I think it's incredibly unlikely anyone actually used that. I still feel we should call it out in the CHANGELOG, though. But yeah, I'm comfortable with this moving forward with the old, broken behaviour but now as a set, and doing new, fixed behaviour for 2.0. |
I just opened #733 changing only |
Closed by #2203 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Fixes #547
Anybody knows why the update method was so complicated?
I refactored the methods to use the expand/flatten pattern we are using for most resources.