terraform-example-foundation icon indicating copy to clipboard operation
terraform-example-foundation copied to clipboard

fix: tf plan truncated on PR comments and plan_validate_all error logs in github actions

Open nbugden opened this issue 1 year ago • 1 comments

Context: The terraform plan generated in GitHub Actions is often truncated when the comment is posted to a PR. This is because the comment is posting the stdout for all environments not just the plan generated by terraform. This PR logs the terraform plan as a separate text file for each environment and then uses those files to create 1 comment per environment on the PR from GitHub Actions.

This also removes the need for #1113 as stdout from the plan_validate_all stage is no longer written to a file.

Issue(s) Resolved: #1109 #1130

nbugden avatar Mar 01 '24 20:03 nbugden

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.

google-cla[bot] avatar Mar 01 '24 20:03 google-cla[bot]

@rjerrems @eeaton @gtsorbo can one of you folks take a look. PR needs /gcbrun and an approving review.

nbugden avatar Apr 17 '24 18:04 nbugden

@rjerrems @eeaton @gtsorbo can one of you folks take a look. PR needs /gcbrun and an approving review.

Nudge, can I get a review. If there is something else required before review, please let me know.

nbugden avatar Apr 24 '24 12:04 nbugden

/gcbrun

(unsure if it "works" in a nested comment)

apeabody avatar Apr 25 '24 15:04 apeabody

@eeaton @apeabody thanks for triggering the checks! terraform-example-foundation-int-trigger-HubAndSpoke (cloud-foundation-cicd) has failed, but I'm unable to see the logs. Can either of you help me with the error so I can address any changes needed in the PR?

nbugden avatar Apr 26 '24 01:04 nbugden

@eeaton @apeabody thanks for triggering the checks! terraform-example-foundation-int-trigger-HubAndSpoke (cloud-foundation-cicd) has failed, but I'm unable to see the logs. Can either of you help me with the error so I can address any changes needed in the PR?

Might be a flake:

Step #30 - "destroy-networks": === NAME  TestNetworks/production
Step #30 - "destroy-networks":     destroy.go:11: 
Step #30 - "destroy-networks":         	Error Trace:	/builder/home/go/pkg/mod/github.com/gruntwork-io/[email protected]/modules/terraform/destroy.go:11
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:456
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:543
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:556
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/utils/stages.go:31
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:559
Step #30 - "destroy-networks":         	Error:      	Received unexpected error:
Step #30 - "destroy-networks":         	            	'terraform [destroy -auto-approve -input=false -var access_context_manager_policy_id=727108865530 -var remote_state_bucket=bkt-d5y-b-seed-tfstate-1323 -var ingress_policies=[{"from" = {"sources" = {"access_levels" = ["*"]}, "identity_type" = "ANY_IDENTITY"}, "to" = {"resources" = ["*"], "operations" = {"storage.googleapis.com" = {"methods" = ["google.storage.objects.get", "google.storage.objects.list"]}}}}] -var egress_policies=[{"from" = {"identity_type" = "ANY_IDENTITY"}, "to" = {"resources" = ["*"], "operations" = {"storage.googleapis.com" = {"methods" = ["google.storage.objects.get", "google.storage.objects.list"]}}}}] -var perimeter_additional_members=[] -no-color -lock=false]' unsuccessful after 1 retries
Step #30 - "destroy-networks":         	Test:       	TestNetworks/production

apeabody avatar Apr 26 '24 01:04 apeabody

/gcbrun

apeabody avatar Apr 26 '24 01:04 apeabody

Looks like this time both cloud build checks failed. Possibly another flake? I also had to pull in the latest changes. Can you help me with the error so I can address any changes needed in the PR?

nbugden avatar Apr 26 '24 13:04 nbugden

/gcbrun

apeabody avatar Apr 26 '24 15:04 apeabody

Checks have passed. Can a get a review and merge if this is ready to go?

nbugden avatar Apr 26 '24 19:04 nbugden

Pulled in the latest from master, can I get a review as well?

nbugden avatar Apr 30 '24 17:04 nbugden

/gcbrun

nbugden avatar May 03 '24 15:05 nbugden

@nbugden I will try a deploy on github for the review

daniel-cit avatar May 03 '24 19:05 daniel-cit

FYI @daniel-cit I just fixed the named branches in the pipeline triggers. Still had non-production from a bad rebase.

nbugden avatar May 03 '24 20:05 nbugden

@daniel-cit any questions about the PR? Did you get a chance to test it?

nbugden avatar May 07 '24 12:05 nbugden

@nbugden tested image

daniel-cit avatar May 10 '24 02:05 daniel-cit

/gcbrun

daniel-cit avatar May 10 '24 02:05 daniel-cit

/gcbrun

daniel-cit avatar May 10 '24 03:05 daniel-cit

/gcbrun

daniel-cit avatar May 10 '24 18:05 daniel-cit

/gcbrun

daniel-cit avatar May 10 '24 22:05 daniel-cit

/gcbrun

daniel-cit avatar May 10 '24 23:05 daniel-cit

/gcbrun

daniel-cit avatar May 11 '24 03:05 daniel-cit

@daniel-cit one of the integration test pipelines failed

nbugden avatar May 13 '24 12:05 nbugden

/gcbrun

daniel-cit avatar May 13 '24 14:05 daniel-cit

/gcbrun

daniel-cit avatar May 14 '24 12:05 daniel-cit

/gcbrun

daniel-cit avatar May 14 '24 19:05 daniel-cit

/gcbrun

daniel-cit avatar May 16 '24 03:05 daniel-cit

/gcbrun

daniel-cit avatar May 18 '24 03:05 daniel-cit

@apeabody the build is green :)

daniel-cit avatar May 19 '24 18:05 daniel-cit