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

Prioritize disk.DiskSizeGb over disk.InitializeParams.DiskSizeGb #8246

Merged
merged 8 commits into from
Jul 5, 2023

Conversation

seanrmilligan
Copy link
Member

@seanrmilligan seanrmilligan commented Jun 30, 2023

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Generated Terraform providers, and ran make test and make lint in the generated providers to ensure it passes unit and linter tests.
  • Ran relevant acceptance tests using my own Google Cloud project and credentials (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read Write release notes before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I've detected that you're a community contributor. @hao-nan-li, a repository maintainer, has been assigned to assist you and help review your changes.

❓ First time contributing? Click here for more details

Your assigned reviewer will help review your code by:

  • Ensuring it's backwards compatible, covers common error cases, etc.
  • Summarizing the change into a user-facing changelog note.
  • Passes tests, either our "VCR" suite, a set of presubmit tests, or with manual test runs.

You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails.

If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox.


@seanrmilligan
Copy link
Member Author

Note to self to fix the whitespace alignment of added code.

@seanrmilligan
Copy link
Member Author

"disk_size_gb2" needs a better name, but I left it as a placeholder so we could have that conversation in the review.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 1 file changed, 31 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 1 file changed, 31 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_compute_instance_template (121 total tests)
Untested fields: disk.disk_size_gb2

Please add acceptance tests which include these fields.

@modular-magician
Copy link
Collaborator

The provider crashed while running the VCR tests in REPLAYING mode
Please fix it to complete your PR
View the build log

@melinath melinath requested review from melinath and removed request for hao-nan-li June 30, 2023 18:30
Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

FYI tests are crashing due to google_compute_region_instance_template reusing the flatteners and expanders from google_compute_instance_template. Any additional fields would also need to be added there.

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 1 file changed, 31 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 1 file changed, 31 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_compute_instance_template (121 total tests)
Untested fields: disk.disk_size_gb2

Please add acceptance tests which include these fields.

@modular-magician
Copy link
Collaborator

The provider crashed while running the VCR tests in REPLAYING mode
Please fix it to complete your PR
View the build log

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 1 file changed, 12 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 1 file changed, 12 insertions(+), 5 deletions(-))
TF Conversion: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@seanrmilligan seanrmilligan changed the title Add a field to compute instance templates to support changes in the GCP API Prioritize disk.DiskSizeGb over disk.InitializeParams.DiskSizeGb Jul 5, 2023
// The API does not return a disk size value for scratch disks. They are largely only one size,
// so we can assume that size here. Prefer disk.DiskSizeGb over the deprecated
// disk.InitializeParams.DiskSizeGb.
if disk.DiskSizeGb == 0 && disk.InitializeParams.DiskSizeGb == 0 && disk.Type == "SCRATCH" {
Copy link
Member Author

Choose a reason for hiding this comment

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

Possible logic bug, past and present: If the disk is not of type SCRATCH, we move past the if into the else-if and else blocks. I can put a guard here wrapping this entire section checking for SCRATCH, but it more closely emulates the existing code to not do so.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks correct as-is to me. If the disk type is not SCRATCH and both DiskSizeGb fields are 0 we can set disk_size_gb to 0.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 1 file changed, 11 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 1 file changed, 11 insertions(+), 4 deletions(-))
TF Conversion: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@rileykarson rileykarson removed the request for review from melinath July 5, 2023 20:13
@rileykarson rileykarson requested a review from trodge July 5, 2023 20:13
// The API does not return a disk size value for scratch disks. They are largely only one size,
// so we can assume that size here. Prefer disk.DiskSizeGb over the deprecated
// disk.InitializeParams.DiskSizeGb.
if disk.DiskSizeGb == 0 && disk.InitializeParams.DiskSizeGb == 0 && disk.Type == "SCRATCH" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks correct as-is to me. If the disk type is not SCRATCH and both DiskSizeGb fields are 0 we can set disk_size_gb to 0.

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2836
Passed tests 2508
Skipped tests: 295
Affected tests: 33

Action taken

Found 33 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccComputeRegionInstanceTemplate_minCpuPlatform|TestAccComputeRegionInstanceTemplate_guestAcceleratorSkip|TestAccComputeRegionInstanceTemplate_guestAccelerator|TestAccComputeRegionInstanceTemplate_secondaryAliasIpRange|TestAccComputeRegionInstanceTemplate_primaryAliasIpRange|TestAccComputeRegionInstanceTemplate_metadata_startup_script|TestAccComputeRegionInstanceTemplate_subnet_custom|TestAccComputeRegionAutoscaler_regionAutoscalerBasicExample|TestAccComputeRegionInstanceTemplate_subnet_auto|TestAccComputeRegionInstanceTemplate_regionDisks|TestAccComputeInstanceTemplate_withScratchDisk|TestAccComputeInstanceFromTemplate_012_removableFields|TestAccComputeInstanceFromTemplate_overrideScratchDisk|TestAccComputeInstanceFromTemplate_overrideAttachedDisk|TestAccComputeInstanceFromTemplate_overrideBootDisk|TestAccComputeInstanceFromRegionTemplate_basic|TestAccComputeInstanceFromTemplate_self_link_unique|TestAccComputeInstanceFromTemplate_basic|TestAccComputeInstanceTemplate_minCpuPlatform|TestAccComputeInstanceTemplate_guestAcceleratorSkip|TestAccComputeInstanceTemplate_guestAccelerator|TestAccComputeInstanceTemplate_secondaryAliasIpRange|TestAccComputeInstanceTemplate_primaryAliasIpRange|TestAccComputeInstanceTemplate_metadata_startup_script|TestAccComputeFirewallPolicyRule_multipleRules|TestAccComputeRegionInstanceTemplate_with18TbScratchDisk|TestAccComputeInstanceTemplate_subnet_custom|TestAccComputeRegionInstanceTemplate_withScratchDisk|TestAccComputeInstanceTemplate_subnet_auto|TestAccComputeInstanceTemplate_regionDisks|TestAccComputeInstanceTemplate_NetworkAttachment|TestAccComputeInstanceTemplate_disks|TestAccComputeInstanceTemplate_with18TbScratchDisk

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccComputeRegionAutoscaler_regionAutoscalerBasicExample[Debug log]
TestAccComputeInstanceFromTemplate_self_link_unique[Debug log]
TestAccComputeInstanceFromTemplate_basic[Debug log]
TestAccComputeInstanceTemplate_minCpuPlatform[Debug log]
TestAccComputeInstanceTemplate_guestAcceleratorSkip[Debug log]
TestAccComputeInstanceTemplate_guestAccelerator[Debug log]
TestAccComputeInstanceTemplate_regionDisks[Debug log]
TestAccComputeInstanceTemplate_disks[Debug log]
TestAccComputeInstanceTemplate_with18TbScratchDisk[Debug log]

Rerun these tests in REPLAYING mode to catch issues

All tests passed after rerunning REPLAYING mode.


Several tests got terminated during RECORDING mode.
View the build log or the debug log for each test

@trodge trodge merged commit cafdd60 into GoogleCloudPlatform:main Jul 5, 2023
6 of 8 checks passed
Khaledmohamedrefaat pushed a commit to Khaledmohamedrefaat/magic-modules that referenced this pull request Jul 13, 2023
…gleCloudPlatform#8246)

* Add and prefer AttachedDisk.DiskSizeGb over AttachedDisk.InitializeParams.DiskSizeGb

* Fix a paren out of place

* Add DiskSizeGb outside InitializeParams as a separate field.

* Undo unnecessary changes

* use one field instead of two

* use one field instead of two
ericayyliu pushed a commit to ericayyliu/magic-modules that referenced this pull request Jul 26, 2023
…gleCloudPlatform#8246)

* Add and prefer AttachedDisk.DiskSizeGb over AttachedDisk.InitializeParams.DiskSizeGb

* Fix a paren out of place

* Add DiskSizeGb outside InitializeParams as a separate field.

* Undo unnecessary changes

* use one field instead of two

* use one field instead of two
wj-chen pushed a commit to wj-chen/magic-modules that referenced this pull request Aug 1, 2023
…gleCloudPlatform#8246)

* Add and prefer AttachedDisk.DiskSizeGb over AttachedDisk.InitializeParams.DiskSizeGb

* Fix a paren out of place

* Add DiskSizeGb outside InitializeParams as a separate field.

* Undo unnecessary changes

* use one field instead of two

* use one field instead of two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants