-
-
Notifications
You must be signed in to change notification settings - Fork 587
feat(terraform_validate): Expand list of TF errors when t init will rerun, if --retry-once-with-cleanup specified
#991
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
Open
AruneshDwivedi
wants to merge
7
commits into
antonbabenko:master
Choose a base branch
from
AruneshDwivedi:fix/terraform-validate-plugin-cache-race
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7
−4
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a94699
fix: force terraform init when plugin cache and parallelism are both …
AruneshDwivedi 7695906
fix: address review feedback on terraform validate init guard
AruneshDwivedi 254c4d6
fix: handle plugin cache race condition via retry instead of proactiv…
AruneshDwivedi 69694d0
fix(terraform_validate): force parallelism disabled on retry init
AruneshDwivedi ae26d3d
fix: clarify retry is conditional on --retry-once-with-cleanup flag
AruneshDwivedi 97b91d6
Merge branch 'master' into fix/terraform-validate-plugin-cache-race
MaxymVlasov 0585e26
Update hooks/terraform_validate.sh
AruneshDwivedi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,7 @@ function match_validate_errors { | |||||
| "Could not load plugin") return 1 ;; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I found out that it was replaced to different error msg in TF v1.1, so let's update it as well
Suggested change
|
||||||
| "Missing required provider") return 1 ;; | ||||||
| *"there is no package for"*"cached in .terraform/providers") return 1 ;; | ||||||
| *"Could not retrieve the list of available versions for provider"*) return 1 ;; | ||||||
| esac | ||||||
| done < <(jq -rc '.diagnostics[]' <<< "$validate_output") | ||||||
|
|
||||||
|
|
@@ -67,9 +68,11 @@ function match_validate_errors { | |||||
| ####################################################################### | ||||||
| # Unique part of `common::per_dir_hook`. The function is executed in loop | ||||||
| # on each provided dir path. Run wrapped tool with specified arguments | ||||||
| # 1. Check if `.terraform` dir exists and if not - run `terraform init` | ||||||
| # 2. Run `terraform validate` | ||||||
| # 3. If at least 1 check failed - change the exit code to non-zero | ||||||
| # 1. Run `terraform validate` | ||||||
| # 2. If validate fails, run `terraform init` and retry | ||||||
| # 3. If --retry-once-with-cleanup is enabled and plugin cache parallelism | ||||||
| # causes a race condition, the error is caught by match_validate_errors | ||||||
| # and retried with cleanup | ||||||
| # Arguments: | ||||||
| # dir_path (string) PATH to dir relative to git repo root. | ||||||
| # Can be used in error logging | ||||||
|
|
@@ -155,7 +158,7 @@ function per_dir_hook_unique_part { | |||||
|
|
||||||
| common::colorify "yellow" "Re-validating: $dir_path" | ||||||
|
|
||||||
| common::terraform_init "$tf_path validate" "$dir_path" "$parallelism_disabled" "$tf_path" || { | ||||||
| common::terraform_init "$tf_path validate" "$dir_path" "true" "$tf_path" || { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert this. It works fine in some cases
Suggested change
|
||||||
| exit_code=$? | ||||||
| return $exit_code | ||||||
| } | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.