-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Fix issue with GCP Cloud SQL Instance disk_autoresize
#14582
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
Conversation
Haven't looked at your code yet, but as far as I can tell, the default is changing to true but the documentation hasn't been updated yet. Changing the default on our side to be true would be a breaking change in most circumstances, but in this case hasn't the breaking part of it already happened? If so, couldn't we just change the default to true on our side? |
Opened an issue with the Cloud SQL team to try and understand this new behaviour. |
I don't see a way around # 4 there. The backend API changed and our code did not honor what became an implicit |
Ah, forgot one:
|
@danawillow / @paddycarver what do you think? I think the only question is regarding the default value, which the more I think the more I believe we should Either way, the |
Here are the tests results with the code as is, and not the proposed
👍 |
disk_autoresize
disk_autoresize
I think your approach is right, and we definitely need this at the very least to allow people to set the value to false at all. I'm leaning towards I found this line in the read function: |
I'll defer to you two on the question of [Update] I'm being told the change was intentional and believe it is not going to be reverted in the foreseeable future. Concern withdrawn. [/Update]
The original author, IIRC, had a policy of not overwriting changes made outside Terraform, and so limited Terraform's authority to only the fields tracked in the config. We have moved away from this policy to match the rest of the Terraform providers, but the remnants of this haven't all been updated yet. |
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 @danawillow doesn't object, LGTM!
For sql_database_instance , to match the new API default. Also adds diff suppression func for autoresize on 1st gen instances
@danawillow / @paddycarver I just pushed 0bf6ba1 , I'm rerunning the tests now.
Let me know what you think 👍
I'm afraid I don't know why that is. It's counter to Terraforms declarative nature. I'm going to be poking around the GCP Provider and likely removing that behavior as I come across it. An all encompassing sweep of the entire Provider is not really feasible at this time, for me at least 😄 |
All green, everyone OK with this?
|
Gonna trust @catsby's green test results, because I can't get past 500s right now, which I'm pretty sure is just flakiness in the upstream API. I'm still good with this being merged. @danawillow? |
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.
Looks good aside from two very minor maybe-typos!
log.Printf("[ERR] error with regex in diff supression for data.autoresize: %s", err) | ||
} | ||
if !matched { | ||
log.Printf("[DEBUG] suppressing diff on disk.autoresize due to 1st gen instance type") |
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.
typo: disk_autoresize
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.
😱
tier := settings["tier"].(string) | ||
matched, err := regexp.MatchString("db*", tier) | ||
if err != nil { | ||
log.Printf("[ERR] error with regex in diff supression for data.autoresize: %s", err) |
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.
should data.autoresize be disk_autoresize?
Fixed typos in 962ada8, pulling this in! Thanks all |
Of course I forgot to update the docs here. I've done that in a8c2828 |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Hey @danawillow / @paddycarver !
I was looking into the following 3 failing tests as reported by our CI:
TestAccGoogleSqlDatabaseInstance_basic3
TestAccGoogleSqlDatabaseInstance_maintenance
TestAccGoogleSqlDatabaseInstance_slave
They’re all failing with the same error message:
I started digging in and found that indeed the value returned from the API does not match our local value in the test check here. Looking in the resource, I noticed that we only seem to save the value from the API under certain conditions here:
If I’m not mistaken, this block will only set the local
disk_autoresize
if that setting is found in our configuration first, and then only if that local value istrue
, correct? I believe this to be incorrect so I’ve patched it here. There’s also a similar issue inUPDATE
where we only send a value if the new value istrue
, and I’ve fixed that here as well. In order to do this though, I have to addDefault: false
to the schema, so that we’re able to toggle fromtrue
tofalse
(an old issue where Terraform andd.GetOk
), or otherwisesettings["disk_autoresize”]
may not contain a value.After fixing the read, I get the following error from the tests:
Which brings me to the API inconsistencies that maybe you could offer some insight into. The API docs here say that
settings.storageAutoResize
is defaultfalse
:However, due to the way our code was written,
false
was never being sent... indeed it can’t be sent right now without being inForceSendFields
, because the field hasomitempty
on it.Even though
settings.storageAutoResize
is not included in the request, but future response and looking in the web console clearly shows thatsettings.storageAutoResize
is true on the Server side. Can you poke someone on the API side about why this is ending up astrue
?I see the SDK uses
omitempty
a lot. In order to address this, it looks likeForceSendFields
is what I need here. I’ve included that as well.I’m running the tests now, and may need an additional tweak after then run to ensure everything passes, but I wanted to open this now to get your feedback on the major points.
Let me know what you think!