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.
There are no changes in implementation, but some adjustments have been made to the test settings:
(1) Add terraform 1.4.0 to the test matrix
(2) Use a local filesystem mirror on CI
Starting with Terraform v1.4, the global plugin cache is ignored on the first terraform init. This makes caching in CI meaningless: hashicorp/terraform#32129, hashicorp/terraform#32494
To utilize the cache, we use a local filesystem mirror. Strictly speaking, the mirror is only available in Terraform v0.13+, but it is hard to compare versions in bash, so we use the mirror unless v0.x.
https://developer.hashicorp.com/terraform/cli/config/config-file#implied-local-mirror-directories
(3) Export TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE=true in CI
Starting from Terraform v1.4, launching terraform providers in the acceptance test has been failing more frequently with a text file busy error.
After some investigation, I found Go's
os/exec.Cmd.Run()
does not wait for the grandchild process to complete; from the point of view of tfmigrate, the terraform command is the child process, and the provider is the grandchild process.golang/go#23019
If I understand correctly, this is not a Terraform issue and theoretically should occur in versions older than v1.4; the changes in v1.4 may have broken the balance of execution timing and made the test very flaky. I experimented with inserting some sleep but could not get the test to stabilize correctly. After trying various things, I found that the test became stable by enabling the
TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE
flag was introduced in v1.4. This is an escape hatch to revert to the v1.3 equivalent of the global cache behavior change in v1.4.hashicorp/terraform#32726
This behavior change has already been addressed in the previous commit using a local file system mirror, so activating this flag does not seem to make any sense. Even though I have no other reasonable solutions now, please let me know if anyone finds a better solution.