-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add send_secondary_ip_range_if_empty #11410
add send_secondary_ip_range_if_empty #11410
Conversation
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
1 similar comment
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 980 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
Tests analyticsTotal tests: 980 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
@@ -0,0 +1,72 @@ | |||
if v, ok := d.GetOk("send_secondary_ip_range_if_empty"); ok && v.(bool) { | |||
if sv, ok := d.GetOk("secondary_ip_range"); ok { | |||
configValue := d.GetRawConfig().GetAttr("secondary_ip_range").AsValueSlice() |
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 case does this handle, if we've presumably set a known zero value for the field in the CustomizeDiff? Theoretically wouldn't we always get the correct value from d.Get
?
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 is necessary when we remove ConfigModeAttr. After removing it, d.GetChange/d.HasChange loses the diff from the plan, so this ended up necessary to actually trigger the update. It works the same for with and without ConfigModeAttr
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.
d.GetChange/d.HasChange loses the diff from the plan
Just to make sure I have this right- terraform plan
displays a diff, but those functions- the "safe" functions in the SDK- report that it did not?
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 this is a local run without ConfigModeAttr and some added debug logs: gpaste/5449355903631360
setting secondary_ip_range to newly empty
line from the customDiff appears twice as expected
paste/5449355903631360#l=399 are the print logs I added. Here's the code
For good measure, I even added another debug log for if the previous MMv1-generated update code is even triggering. It does not appear
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!
bb20711
to
4cef0f3
Compare
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 980 Click here to see the affected service packages
View the build log |
Co-authored-by: Riley Karson <rileykarson@google.com>
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 980 Click here to see the affected service packages
View the build log |
Co-authored-by: Riley Karson <rileykarson@google.com>
Co-authored-by: Riley Karson <rileykarson@google.com>
part of hashicorp/terraform-provider-google#12824 and hashicorp/terraform-provider-google#17881
adds a virtual field to replace the need to set
secondary_ip_range = []
to removesecondary_ip_range
explicitly. The virtual field in combination withGetRawConfig().GetAttr("secondary_ip_range")
can let us detect when the user has intent to set to an empty list vs intending to let the backend manage the field.Normally, when removing an Optional+Computed field from config, Terraform will not produce a diff. The
sendSecondaryIpRangeIfEmptyDiff
checks if the new flag is set and then compares the config value with the state value usingGetRawConfig()
andGetOk
respectively.The actual update call is handled in a post_update custom code block.
This logic works with and without SchemaConfigModeAttr, allowing an upgrade path in 5.x before removing SchemaConfigModeAttr from
secondary_ip_range
in 6.0Release Note Template for Downstream PRs (will be copied)