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

Optimize state merging process when there is no base state given #347

Merged
merged 6 commits into from
Feb 1, 2023

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Jan 31, 2023

Previously, we were using tfmerge to merge the import state file and the base state file, by a per resource movement manner. This is fine in most cases. But there is still a space to improve the performance, when there is no base state given (i.e. not appending to an existing workspace). In this case, as long as the import items have no address conflicts (guaranteed by aztfy), it can safely merge the state files by simply appending (resources field). Also since this state file is a fresh new one, there is no special requirement on the serial and lineage.

This PR also makes some other less related changes to make it more intuitive for library users:

  • Remove the rootdir (i.e. cache dir) creation from NewMeta(). The cache dir is only used to cache an auto-downloaded terraform binary. We now eliminate this behavior due to as a library, this method shall be thread-safe, and we try to avoid downloading behavior as possible. As a result, aztfy now depends on a pre-installed terraform executable that is located at $PATH. Hence mark this PR as a breaking-change.
  • Move the import directories creation to meta.Init(), to make it match the tear-down operations in meta.DeInit()
  • Config now replaces .Append by .OutputFileNames to be more clear

…orm`

- Remove the rootdir (i.e. cache dir) creation from `NewMeta()`. The cache dir is only used to cache an auto-downloaded terraform binary. We now eliminate this behavior due to as a library, this method shall be thread-safe, and we try to avoid downloading behavior as possible.
- Move the import directories creation to `meta.Init()`, to make it match the tear-down operations in `meta.DeInit()`
@magodo magodo requested a review from ms-henglu January 31, 2023 09:23
@magodo magodo added enhancement New feature or request breaking-change labels Jan 31, 2023
@magodo magodo merged commit 84e5752 into Azure:main Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants