terraform: copy RawConfigs to avoid races #1454
Merged
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.
Fixes #1416 probably
This adds a
Copy
method to*config.RawConfig
that performs a parallel-safe copy. The reason this is necessary is because*config.RawConfig.Interpolate
has a slight race in the way it reads from and writes tor.config
at the same time.While I couldn't come up with a test case to prove it, I'm very confident this is what caused #1416. The key there being that in his repro, one of them isn't interpolated at all. I think this is because it wrote
r.config
properly but then another interpolation overwrote it with a raw version, and interpolation didnt' see those values.I can't be 100% sure. I couldn't reproduce the bug, but looking over the code this was the only shared state that I could find anywhere.