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

[#9353] Make cloud router sort advertised_ip_ranges in state by config order #10572

Merged

Conversation

LucaPrete
Copy link
Member

@LucaPrete LucaPrete commented May 1, 2024

Use the new function introduced in #10410 to order advertised_ip_ranges properties according to the order in config.

Pre-6.0.0 fix for hashicorp/terraform-provider-google/issues/9353.

Release Note Template for Downstream PRs (will be copied)

compute: fixed permadiff in ordering of `advertised_ip_ranges.range` field on `google_compute_router` resource.

Copy link

github-actions bot commented May 1, 2024

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@SarahFrench, 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.

Luca Prete added 2 commits May 1, 2024 13:34
@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.

google provider: Diff ( 2 files changed, 16 insertions(+), 14 deletions(-))
google-beta provider: Diff ( 2 files changed, 16 insertions(+), 14 deletions(-))

@LucaPrete
Copy link
Member Author

@SarahFrench I can't understand from our CloudBuild logs what's failing. Do you find any useful log anywhere?

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 78
Passed tests: 20
Skipped tests: 58
Affected tests: 0

Click here to see the affected service packages
  • compute

$\textcolor{red}{\textsf{Errors occurred during RECORDING mode. Please fix them to complete your PR.}}$
View the build log

@LucaPrete
Copy link
Member Author

LucaPrete commented May 1, 2024

Once this gets passes the tests and gets reviewed, I can also put (here or through another PR) the same flatten function for advertised_ip_ranges in google_compute_router_peer here.

Copy link
Collaborator

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

I'll look in more depth tomorrow, but in case it helps unblock you the error is:

Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1/templates/terraform/custom_flatten/compute_router_range.go.erb
Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1/templates/terraform/flatten_property_method.erb
Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1/templates/terraform/flatten_property_method.erb
Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1//templates/terraform/resource.erb
bundler: failed to load command: compiler.rb (compiler.rb)
(erb):2:in `compile_template': undefined local variable or method `range' for #<Provider::Terraform:0x0000000104c75fb0 @api=#<Api::Product:0x0000000104e257e8 @name="Compute", @display_name="Compute Engine", @version

@LucaPrete
Copy link
Member Author

I'll look in more depth tomorrow, but in case it helps unblock you the error is:


Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1/templates/terraform/custom_flatten/compute_router_range.go.erb

Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1/templates/terraform/flatten_property_method.erb

Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1/templates/terraform/flatten_property_method.erb

Error compiling file: /.../GoogleCloudPlatform/magic-modules/mmv1//templates/terraform/resource.erb

bundler: failed to load command: compiler.rb (compiler.rb)

(erb):2:in `compile_template': undefined local variable or method `range' for #<Provider::Terraform:0x0000000104c75fb0 @api=#<Api::Product:0x0000000104e257e8 @name="Compute", @display_name="Compute Engine", @version

@SarahFrench thank you! With the message you provided is all clear but I'm wondering where you found it. I do have access to CB logs but I still can't find any.

@github-actions github-actions bot requested a review from SarahFrench May 2, 2024 12:46
@SarahFrench
Copy link
Collaborator

SarahFrench commented May 2, 2024

I'm wondering where you found it. I do have access to CB logs but I still can't find any.

I think the logs in Cloud Build omitted a bunch of log lines. The logs show ... omitting 1869281 bytes ... in the place where that error would be shown.

I investigating the error by generating the provider from your PR's branch on my laptop, following this guidance: https://googlecloudplatform.github.io/magic-modules/get-started/generate-providers/

@github-actions github-actions bot requested a review from SarahFrench May 2, 2024 14:17
@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.

google provider: Diff ( 2 files changed, 28 insertions(+), 3 deletions(-))
google-beta provider: Diff ( 2 files changed, 28 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 685
Passed tests: 613
Skipped tests: 72
Affected tests: 0

Click here to see the affected service packages
  • compute

$\textcolor{red}{\textsf{Errors occurred during RECORDING mode. Please fix them to complete your PR.}}$
View the build log

})
}
configData := []map[string]interface{}{}
for _, item := range d.Get("advertisedIpRanges.0.range").([]interface{}) {
Copy link
Collaborator

@SarahFrench SarahFrench May 2, 2024

Choose a reason for hiding this comment

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

The error mentioned here is due to the problem below, and I think the test that first encountered the error was TestAccComputeRouter_noRegion

panic: interface conversion: interface {} is string, not []interface {}

goroutine 4529793 [running]:
github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute.flattenComputeRouterBgpAdvertisedIpRangesRange({0x3e85f60?, 0xc016c89f40?}, 0x4763f12?, 0x5?)
	/go/src/github.com/modular-magician/terraform-provider-google-beta/google-beta/services/compute/resource_compute_router.go:654 +0x4e9

Copy link
Collaborator

Choose a reason for hiding this comment

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

I attached my comment to the wrong line - L654 mentioned in the panic is here

Copy link
Member Author

Choose a reason for hiding this comment

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

@SarahFrench apologies if I disappeared but I'm in and out working at other customers.

I'm not able to debug this code now as

  • I can't run the test on my computer. Both the GA and the beta provider seem to be failing in this exact moment
  • The lines reported in the build log and in the diff don't seem to correspond

I'd probably need to log some things here and there to be able to say more. As soon as I'll find again some time I'll try again and let you know. In the meantime, if you see anything obvious, please let me know.

Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

The lines reported in the build log and in the diff don't seem to correspond

The panic output I posted above refers to the code in the provider that's built from the Magic Modules repo. If you click the links on Diff Report posts on the PR it'll show the resulting provider code from your PR and the lines should correspond. A useful bit of context is that the tests that run on PRs use the google-beta code generated from the PR, so if there are differences in a file between the GA and Beta versions of the provider that could result in some code line confusion too.

No worries about juggling other tasks, that's totally understandable!

Copy link
Member Author

Choose a reason for hiding this comment

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

@SarahFrench there's something I'm clearly not understanding here :)

If I build the GA provider on my computer and run TestAccComputeRouter_noRegion I never get an error.
I guess the first thing I wish is being able to reproduce it in my local environment, so I can debug it and understand what's going on.

You said you got the error during your local build. May I ask you how you got to the error exactly?

FYI my commands:

make provider VERSION=ga OUTPUT_PATH="$GOPATH/src/github.com/hashicorp/terraform-provider-google" PRODUCT=compute
cd $GOPATH/src/github.com/hashicorp/terraform-provider-google
make testacc TEST=./google/services/compute TESTARGS='-run=TestAccComputeRouter_noRegion'

What am I missing? Also, are you a Googler? If you are, can you please reach me in chat? Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

👋 I'm a HashiCorp employee so I'm afraid this PR is the best place for us to talk.

If I build the GA provider on my computer and run TestAccComputeRouter_noRegion I never get an error.

I'll have a go running the Compute tests against your PR, the output where the panic was reported may have been misleading about which test triggered the problem. I'll report back!

You said you got the error during your local build. May I ask you how you got to the error exactly?

Do you mean when I helped with the build error here? That build error is separate to the panic that we're now seeing when the tests are running using the built provider code.

@github-actions github-actions bot requested a review from SarahFrench May 6, 2024 09:05
@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.

google provider: Diff ( 2 files changed, 16 insertions(+), 14 deletions(-))
google-beta provider: Diff ( 2 files changed, 16 insertions(+), 14 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 135
Passed tests: 77
Skipped tests: 58
Affected tests: 0

Click here to see the affected service packages
  • compute

$\textcolor{red}{\textsf{Errors occurred during RECORDING mode. Please fix them to complete your PR.}}$
View the build log

Copy link
Collaborator

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Reviewing again as GHA automation re-requested review from me, but see previous discussion for next steps

Copy link

@LucaPrete, this PR is waiting for action from you. Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

If no action is taken, this PR will be closed in 28 days.

This notification can be disabled with the disable-automatic-closure label.

@SarahFrench
Copy link
Collaborator

I'm running individual tests in TeamCity to test this PR (see #10572 (comment)) but I'll re-trigger tests on this PR directly too:

/gcbrun

@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.

google provider: Diff ( 2 files changed, 16 insertions(+), 14 deletions(-))
google-beta provider: Diff ( 2 files changed, 16 insertions(+), 14 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 78
Passed tests: 20
Skipped tests: 58
Affected tests: 0

Click here to see the affected service packages
  • compute

$\textcolor{red}{\textsf{Errors occurred during REPLAYING mode. Please fix them to complete your PR.}}$
View the build log

@SarahFrench
Copy link
Collaborator

SarahFrench commented May 22, 2024

Tests that triggered the panic in our testing environment when I ran all Compute tests against this PR:

  • TestAccComputeRouter_addAndUpdateIdentifierRangeBgp
  • TestAccComputeRouter_full
  • TestAccComputeRouter_routerBasicExample
  • TestAccComputeRouter_update

All the panics point to google-beta/services/compute/resource_compute_router.go:649.

The data coming from the API before the panic is a GET request to get the resource's data:

Expand me to see the API interaction
---[ REQUEST ]---------------------------------------
GET /compute/beta/projects/PROJECT_ID/regions/us-central1/routers/tf-test-router-21774xuy3t?alt=json HTTP/1.1
Host: compute.googleapis.com
User-Agent: Terraform/1.8.3 (+https://www.terraform.io) Terraform-Plugin-SDK/2.33.0 terraform-provider-google-beta/dev
Content-Type: application/json
Accept-Encoding: gzip


-----------------------------------------------------
2024/05/21 15:58:25 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Tue, 21 May 2024 15:58:25 GMT
Etag: c3IxE2a5zjtzwTTfPRfkArR717Q=/89RsJ8v3AuKyB9cl514K1xCfAH0=
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
  "kind": "compute#router",
  "id": "6599853179148532362",
  "creationTimestamp": "2024-05-21T08:57:25.107-07:00",
  "name": "tf-test-router-21774xuy3t",
  "description": "",
  "region": "https://www.googleapis.com/compute/beta/projects/PROJECT_ID/regions/us-central1",
  "network": "https://www.googleapis.com/compute/beta/projects/PROJECT_ID/global/networks/tf-test-router-21774xuy3t-net",
  "bgp": {
    "asn": 64514,
    "advertiseMode": "CUSTOM",
    "advertisedGroups": [
"ALL_SUBNETS"
    ],
    "advertisedIpRanges": [
      {
        "range": "1.2.3.4",
        "description": ""
      },
      {
        "range": "6.7.0.0/16",
        "description": ""
      }
    ],
    "keepaliveInterval": 25
  },
  "selfLink": "https://www.googleapis.com/compute/beta/projects/PROJECT_ID/regions/us-central1/routers/tf-test-router-21774xuy3t",
  "encryptedInterconnectRouter": false
}

Copy link
Collaborator

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Could you please take a look at my suggested code change, and if you're able could you please try running the TestAccComputeRouter_full test locally?

…o.erb

Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
@github-actions github-actions bot requested a review from SarahFrench May 23, 2024 11:14
@LucaPrete
Copy link
Member Author

@SarahFrench thanks a lot! I committed your proposed change. Your help has been key! Let's see if we have more tests complaining now...

@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.

google provider: Diff ( 2 files changed, 18 insertions(+), 14 deletions(-))
google-beta provider: Diff ( 2 files changed, 18 insertions(+), 14 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 933
Passed tests: 861
Skipped tests: 72
Affected tests: 0

Click here to see the affected service packages
  • compute

$\textcolor{green}{\textsf{All tests passed!}}$
View the build log

Copy link
Collaborator

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

I reproduced the original issue from hashicorp/terraform-provider-google#9353 locally with the latest google provider release and saw the reordering diff, and with the provider built from this PR the diff isn't there anymore! 🎉

Given the existing tests are passing ok and my manual test I'm happy to merge

@SarahFrench
Copy link
Collaborator

Thanks for your work on this @LucaPrete!

@SarahFrench SarahFrench merged commit 43a016f into GoogleCloudPlatform:main May 23, 2024
15 checks passed
Cheriit pushed a commit to Cheriit/magic-modules that referenced this pull request Jun 4, 2024
…s in state by config order (GoogleCloudPlatform#10572)

Co-authored-by: Luca Prete <lucaprete@google.com>
Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
jessdejong pushed a commit to jessdejong/magic-modules that referenced this pull request Jun 10, 2024
…s in state by config order (GoogleCloudPlatform#10572)

Co-authored-by: Luca Prete <lucaprete@google.com>
Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
pcostell pushed a commit to pcostell/magic-modules that referenced this pull request Jul 16, 2024
…s in state by config order (GoogleCloudPlatform#10572)

Co-authored-by: Luca Prete <lucaprete@google.com>
Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants