Skip to content
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

🐛 Fix nil pointer if no cluster autoscaling #1766

Merged
merged 3 commits into from
Feb 27, 2020
Merged

🐛 Fix nil pointer if no cluster autoscaling #1766

merged 3 commits into from
Feb 27, 2020

Conversation

bakayolo
Copy link
Contributor

@megan07
Copy link
Contributor

megan07 commented Feb 19, 2020

Hi @bappr! Thank you for your contribution. I'm unable to reproduce the error that you're getting, would you be able to give me the configuration you have that is leading to this error? Or add a test that fails before this change, but passes after?
Thanks!

@bakayolo
Copy link
Contributor Author

Hey @megan07,
So basically, it's on this function that is here https://github.com/terraform-providers/terraform-provider-google-beta/pull/1766/files#diff-1d8fddb33edfcab666a2f3539719ddf3R2722

flattenClusterAutoscaling(a *containerBeta.ClusterAutoscaling)

When a is nil, it's failing.
I checked and unfortunately there is no test already there for that.

FYI, it's not failing when planning but applying.

@megan07
Copy link
Contributor

megan07 commented Feb 21, 2020

@bappr, thank you for the clarification! I've spent some time digging into this, and I think my confusion is the fact that a == nil and !a.EnableNodeProvisioning should not be considered equivalent in this conditional. It appears AutoscalingProfile can be set regardless of the value of EnabledNodeProvisioning, which I'm guessing is why it is being set outside that block. However, you're absolutely right that this will cause issues when a is nil.

That being said, I propose we split this into two conditionals (a == nil and a.EnableNodeProvisioning) where the previous fields are set inside the a.EnableNodeProvisioning block, and a == nil returns nil? (I think that's how other nil objects are handled).

Would you like to take a stab at that, or would you like us to make that change?

Thanks for catching this!

@bakayolo
Copy link
Contributor Author

Hey @megan07
Oh yes you're right. Did not see it was "NodeProvisioning". I thought it was "NodeAutoscaling" and therefore, it did not make much sense. :)
Anyway, I added the fix. FYI, I did not return nil if a == nil since it's not the original behaviour (r["enabled"]=false) and I am afraid it could break something somewhere else.

Copy link
Contributor

@megan07 megan07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

google-beta/resource_container_cluster.go Outdated Show resolved Hide resolved
Copy link
Contributor

@emilymye emilymye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@megan07 sorry to take over, but we've had a couple issues filed - I'm going to go ahead and upstream this one and then merge the PRs in.

@emilymye emilymye merged commit 148c3c9 into hashicorp:master Feb 27, 2020
emilymye added a commit to emilymye/magic-modules that referenced this pull request Feb 27, 2020
@bakayolo bakayolo deleted the patch-1 branch February 27, 2020 03:31
emilymye added a commit to GoogleCloudPlatform/magic-modules that referenced this pull request Feb 27, 2020
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this pull request Feb 27, 2020
Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit to hashicorp/terraform-provider-google that referenced this pull request Feb 27, 2020
Signed-off-by: Modular Magician <magic-modules@google.com>
emilymye pushed a commit to emilymye/terraform-provider-google-beta that referenced this pull request Mar 2, 2020
* 🐛 Fix nil pointer if no cluster autoscaling

Related to hashicorp/terraform-provider-google#5685

* 🐛 PR Comments

* 🐛PR comments 2
emilymye pushed a commit to emilymye/terraform-provider-google that referenced this pull request Mar 2, 2020
… (hashicorp#5782)

Signed-off-by: Modular Magician <magic-modules@google.com>
emilymye added a commit to hashicorp/terraform-provider-google that referenced this pull request Mar 2, 2020
#5807)

Signed-off-by: Modular Magician <magic-modules@google.com>

Co-authored-by: The Magician <magic-modules@google.com>
emilymye added a commit that referenced this pull request Mar 2, 2020
* 🐛 Fix nil pointer if no cluster autoscaling

Related to hashicorp/terraform-provider-google#5685

* 🐛 PR Comments

* 🐛PR comments 2

Co-authored-by: Appréderisse Benjamin <benjamin.apprederisse@gmail.com>
nathkn pushed a commit to nathkn/magic-modules that referenced this pull request May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants