azurerm_virtual_network - Remove read-only properties from subnet payloads to avoid ARM API limit errors#30945
Conversation
…ayloads to avoid ARM API limit errors
3495f30 to
3ab2840
Compare
|
LGTM! |
WodansSon
left a comment
There was a problem hiding this comment.
Hi @ezhong-msft, this mostly LGTM, but I did have a question about the implementation. I just want to make sure I understand it correctly without a whole lot of context. I believe I get it but I wanted to touch base with you to make sure I fully grok the issue. 🚀
| } else if payload.Properties.Subnets != nil { | ||
| // remove readonly properties as they are not managed by TF - large networks can cause ARM API limit errors | ||
| for i := range *payload.Properties.Subnets { | ||
| (*payload.Properties.Subnets)[i].Properties.IPConfigurations = nil | ||
| (*payload.Properties.Subnets)[i].Properties.PrivateEndpoints = nil | ||
| } |
There was a problem hiding this comment.
So we only want to remove these read-only properties if the subnet field hasn't change because we are getting the payload from the model being returned from Azure instead of building it in the expand function which means it will contain all of the read-only fields, is that correct?
There was a problem hiding this comment.
I thought the expand builds the subnet from scratch without the read-only fields but seems like it actually fetches the subnet from API too... I don't think the else-if condition is even necessary anyway so I'll remove it and clear it in all cases
WodansSon
left a comment
There was a problem hiding this comment.
@ezhong-msft, thank you for pushing those changes, this LGTM now! 🚀
jackofallops
left a comment
There was a problem hiding this comment.
Thanks @ezhong-msft - One comment to take a look at if you could, then I think this will be fine.
| if payload.Properties.Subnets != nil { | ||
| // remove readonly properties as they are not managed by TF - large networks can cause ARM API limit errors | ||
| for i := range *payload.Properties.Subnets { | ||
| if (*payload.Properties.Subnets)[i].Properties != nil { | ||
| (*payload.Properties.Subnets)[i].Properties.IPConfigurations = nil | ||
| (*payload.Properties.Subnets)[i].Properties.PrivateEndpoints = nil | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
payload.Properties could be nil here, causing a crash. Can we move this reset of the R/O properties to inside the correctly nil-checked if payload.Properties != nil && payload.Properties.Subnets != nil { below so we don't need to perform the same check twice?
There was a problem hiding this comment.
I would have thought it would be captured by the check above.
But have moved it down to avoid the duplicate check and looping through the subnets 👍
jackofallops
left a comment
There was a problem hiding this comment.
Thanks @ezhong-msft - This LGTM now 👍
|
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. |
Community Note
Description
Doing an update on virtual network in Terraform involves pulling the existing state from the API. This contains some properties that aren't tracked by Terraform and are read-only so are not required for an update. For large vnet architectures (e.g. >10k private endpoints), these extraneous properties being passed back in the update payload can cause a
RequestContentTooLargeARM API error as it exceeds the 4MB payload limit, blocking any updating occuring.PR Checklist
n\aI have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
n/aI have written new tests for my resource or datasource changes & updated any relevant documentation.n\a(For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.Testing
https://hashicorp.teamcity.com/buildConfiguration/TF_AzureRM_AZURERM_SERVICE_PUBLIC_NETWORK/510686?buildTab=tests
Some other resources with dependencies on
azurerm_virtual_network:https://hashicorp.teamcity.com/buildConfiguration/TF_AzureRM_AZURERM_SERVICE_PUBLIC_APPSERVICE/510690?buildTab=overview
https://hashicorp.teamcity.com/buildConfiguration/TF_AzureRM_AZURERM_SERVICE_PUBLIC_NETWORK/510688?buildTab=tests
https://hashicorp.teamcity.com/buildConfiguration/TF_AzureRM_AZURERM_SERVICE_PUBLIC_COMPUTE/510689?buildTab=tests
Failures seem to be pre-existing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_resource- support for thething1property [GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #0000
AI Assistance Disclosure
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.