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

Compute: add support for instance reservation_affinity #4335

Conversation

mhuxtable
Copy link
Contributor

reservation_affinity controls how instances or instances created from
templates consume Compute Engine resource reservations.

Fixes hashicorp/terraform-provider-google#4593

This hoists my PR from hashicorp/terraform-provider-google#7669 up to magic-modules so this effort is not on someone else to do.

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).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests. – I ran the subset of tests relating to added functionality
  • 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). - tests added
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know). - ran the specific subset of tests added for this functionality
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

compute: added `reservation_affinity` to `google_compute_instance` and `google_compute_instance_template`

@modular-magician
Copy link
Collaborator

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

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review.

Thanks for your contribution! A human will be with you soon.

@rileykarson, please review this PR or find an appropriate assignee.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 409 insertions(+))
Terraform Beta: Diff ( 6 files changed, 410 insertions(+), 1 deletion(-))
TF Conversion: Diff ( 1 file changed, 51 insertions(+))

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

LGTM so far, running tests. One small comment about the test case formatting (inline)

/gcbrun

func testAccComputeInstance_reservationAffinityConfig(instanceName, reservationType string) string {
var reservationCfg, reservationInstanceCfgSection string

if reservationType == "SPECIFIC_RESERVATION" {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of conditional logic, can you duplicate the config so that we've got one for SPECIFIC_RESERVATION and another for the other two cases? Not only is that easier to reason about, it's pretty common for us to copy+paste these configs to debug them or to get a working copy of a resource for a field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I've split that into two and ditched the branching in both this and the compute_instance_template resource.

@mhuxtable
Copy link
Contributor Author

@rileykarson thanks for the review. I've revised the tests as requested and re-run the subset of tests I've added against a local GCP project; all passed.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 455 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 6 files changed, 455 insertions(+), 5 deletions(-))
TF Conversion: Diff ( 1 file changed, 51 insertions(+))

}

func testAccComputeInstance_reservationAffinity_specificReservationConfig(instanceName string) string {
return `
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return `
return fmt.Sprintf(`

I think this is just missing a Sprintf, but it could be more! Mind double checking that this compiles+runs? Thanks!

Relevant test log lines:

go test  -timeout=30s $(go list ./...)
# github.com/hashicorp/terraform-provider-google-beta/v3/google-beta
google-beta/resource_compute_instance_test.go:4740:17: expected statement, found ')'
FAIL	github.com/hashicorp/terraform-provider-google-beta/v3/google-beta [setup failed]
?   	github.com/hashicorp/terraform-provider-google-beta/v3	[no test files]
?   	github.com/hashicorp/terraform-provider-google-beta/v3/scripts/affectedtests	[no test files]
?   	github.com/hashicorp/terraform-provider-google-beta/v3/scripts/sidebar	[no test files]
?   	github.com/hashicorp/terraform-provider-google-beta/v3/version	[no test files]
FAIL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. This was indeed just a missing Sprintf – had it locally as an uncommitted change. Should be good to go now – have verified compilation.

@mhuxtable mhuxtable requested a review from rileykarson January 9, 2021 00:15
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

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

@dvmorris
Copy link

What is holding this up from being merged? Is there anything I can do to help? I need this functionality.

@rileykarson
Copy link
Member

Sorry about the delay here- I lost track of this PR, likely accidentally dismissing the notification email while cleaning my inbox out.

@mhuxtable: Would you be able to rebase it? It looks like some conflicts have popped up since I last took a look. I'll clone and complete it otherwise.

Matthew Huxtable added 3 commits May 27, 2021 21:09
reservation_affinity controls how instances or instances created from
templates consume Compute Engine resource reservations.

Closes GoogleCloudPlatform#4593
@mhuxtable mhuxtable force-pushed the mhuxtable/compute_instance_reservation_affinity branch from 2246bf4 to 29e262d Compare May 27, 2021 20:56
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 449 insertions(+))
Terraform Beta: Diff ( 6 files changed, 450 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 51 insertions(+))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=189477"

@mhuxtable
Copy link
Contributor Author

Sorry about the delay here- I lost track of this PR, likely accidentally dismissing the notification email while cleaning my inbox out.

@mhuxtable: Would you be able to rebase it? It looks like some conflicts have popped up since I last took a look. I'll clone and complete it otherwise.

@rileykarson that's done and the tests re-run.

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccComputeInstanceTemplate_reservationAffinities|TestAccComputeInstance_reservationAffinities You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=189478"

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

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.

Add reservationAffinity to google_compute_instance
4 participants