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

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

Merged
merged 10 commits into from
May 20, 2024

Conversation

nbugden
Copy link
Contributor

@nbugden nbugden commented Mar 1, 2024

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 nbugden requested review from rjerrems, gtsorbo and a team as code owners March 1, 2024 20:14
Copy link

google-cla bot commented Mar 1, 2024

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.

@nbugden nbugden requested a review from eeaton as a code owner April 3, 2024 20:22
@nbugden nbugden force-pushed the fix/gh-comments branch 2 times, most recently from 38779ca to 60b9950 Compare April 15, 2024 13:43
@nbugden
Copy link
Contributor Author

nbugden commented Apr 17, 2024

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

@nbugden
Copy link
Contributor Author

nbugden commented Apr 24, 2024

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

@@ -139,7 +139,7 @@ convert_path() {
## Terraform apply for single environment.
tf_apply() {
local path=$1
local tf_env="${path#$base_dir/}"
local tf_env="${path#"$base_dir"/}"
Copy link
Contributor

Choose a reason for hiding this comment

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

These are good - usually the pr lint flags these - I have had to wrap all vars before in other repos

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks
Seems the linter has been Expected — Waiting for status to be reported for a number of weeks (possibly waiting for an approval to run). I validated locally using shellcheck. If this is likely to get flagged by the linter I can change it back as it is not functional change that is part of the PR.

For reference here is the issue flagged by shellcheck: https://www.shellcheck.net/wiki/SC2295

Copy link
Collaborator

Choose a reason for hiding this comment

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

/gcbrun to get the linter going

@apeabody
Copy link
Contributor

/gcbrun

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

@nbugden
Copy link
Contributor Author

nbugden commented Apr 26, 2024

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

@apeabody
Copy link
Contributor

@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/terratest@v0.46.11/modules/terraform/destroy.go:11
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.12.1/pkg/tft/terraform.go:456
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.12.1/pkg/tft/terraform.go:543
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.12.1/pkg/tft/terraform.go:556
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.12.1/pkg/utils/stages.go:31
Step #30 - "destroy-networks":         	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/blueprint-test@v0.12.1/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
Copy link
Contributor

/gcbrun

@nbugden
Copy link
Contributor Author

nbugden commented Apr 26, 2024

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?

@apeabody
Copy link
Contributor

/gcbrun

@nbugden
Copy link
Contributor Author

nbugden commented Apr 26, 2024

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

@nbugden
Copy link
Contributor Author

nbugden commented Apr 30, 2024

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

@nbugden nbugden force-pushed the fix/gh-comments branch 3 times, most recently from 525b3ce to b7db511 Compare May 2, 2024 12:54
@nbugden
Copy link
Contributor Author

nbugden commented May 3, 2024

/gcbrun

@daniel-cit
Copy link
Contributor

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

@nbugden
Copy link
Contributor Author

nbugden commented May 3, 2024

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

@nbugden
Copy link
Contributor Author

nbugden commented May 7, 2024

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

@daniel-cit
Copy link
Contributor

@nbugden tested
image

@daniel-cit
Copy link
Contributor

/gcbrun

Copy link
Contributor

@daniel-cit daniel-cit left a comment

Choose a reason for hiding this comment

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

LGTM

@daniel-cit
Copy link
Contributor

/gcbrun

4 similar comments
@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

/gcbrun

@nbugden
Copy link
Contributor Author

nbugden commented May 13, 2024

@daniel-cit one of the integration test pipelines failed

@daniel-cit
Copy link
Contributor

/gcbrun

1 similar comment
@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

/gcbrun

@daniel-cit
Copy link
Contributor

@apeabody the build is green :)

Copy link
Contributor

@apeabody apeabody left a comment

Choose a reason for hiding this comment

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

already approved and no change to module code

@apeabody apeabody merged commit aee08a4 into terraform-google-modules:master May 20, 2024
5 checks passed
@nbugden nbugden deleted the fix/gh-comments branch May 20, 2024 20:57
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.

None yet

5 participants