compute: don't flatten API-provided boot disk resource_policies into an unset field - #18894
Open
pose wants to merge 2 commits into
Open
compute: don't flatten API-provided boot disk resource_policies into an unset field#18894pose wants to merge 2 commits into
pose wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Ported onto the map-based flattenBootDisk.
pose
force-pushed
the
fix-compute-instance-resource-policies
branch
from
September 8, 2026 15:23
4ac07f7 to
9d16cfa
Compare
pose
marked this pull request as ready for review
September 8, 2026 16:49
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Picks up #16888, which was auto-closed for inactivity after its RECORDING run failed. Rebased onto current main, where
flattenBootDiskworks on rawmap[string]interface{}, so the change is ported rather than replayed; the provider fix stays under @corymhall's authorship.flattenBootDiskcopies the boot disk's resource policies intoboot_disk.initialize_params.resource_policies, reading them from a GET on the disk because the instance GET omitsinitializeParams. There, policies set inline at create time are indistinguishable from ones attached withgoogle_compute_disk_resource_policy_attachment, so a disk with out of band policies populates a field the config never set, sometimes with more entries than itsMaxItems: 1. The existing guard compared againstnil, which aTypeListread never returns, so it never fired.Abbreviated from
TestComputeInstance_flattenBootDiskResourcePolicies:The guard now uses
GetOkExists+tpgresource.IsEmptyValue, so that a present-but-empty value counts as unset, and it moves into the branch where the disk lookup succeeded, which is the only place the disk's own fields are read.An import read starts from an empty state, so the field is left unset there too: nothing says whether the disk's policies belong to
initialize_params, and importing them can overflow the list. Sibling fields in the same flatten (snapshot,source_image_encryption_key,resource_manager_tags) are already empty on import. Step 6 ofTestAccComputeInstance_diskResourcePolicies_attachmentDifffailed on exactly this in the RECORDING run and now ignores the attribute; the two earlier import steps still assert that attachment policies do not leak into the field.Internal tests cover the create, refresh and import shapes of the read plus the disk-lookup error path. All four unset-field cases fail against the old guard.
Context: pulumi/pulumi-gcp#3666