Open mickeder opened 4 days ago
Hey @mickeder
Terragrunt does have to fetch dependencies recursively, as ancestor dependencies can influence outputs of immediate parents.
It should be caching the outputs of ancestor dependencies to minimize the performance penalty, however. Have you done a performance analysis to see what the impact has been in the latest version of Terragrunt?
You can take advantage of the OpenTelemetry integration to get more insight on that: https://terragrunt.gruntwork.io/docs/features/debugging/#opentelemetry-integration
Hi @yhakbar, as I stated in my report, I tested it with the newest version of Terragrunt. It doesn't matter which version I use, after version 0.55.3 outputs of all ancestor dependencies are fetched, even though it was not the case before. The current behavior is also not reflected in the documentation that I mentioned (Can I speed up dependency fetching?), which states:
If these conditions are met, terragrunt will only parse out the remote_state blocks and use that to pull down the state for the target module without parsing the dependency blocks, avoiding the recursive dependency retrieval.
In my opinion, the new feature implemented in version 0.55.4 giving the ability to reference inputs of dependencies broke the previous behavior and was not designed to change this in the first place.
Describe the bug
Recently I've noticed that newer versions of Terragrunt run very slow when there are many recursive dependencies. This was not the case in the past, and I pinpointed the version where it changed to 0.55.4 - the introduction of
Reference to dependency inputs
.According to the documentation about dependency block, there is a way to fetch only the outputs of the lowest level dependencies by using
remote_state block
. This way the outputs are not fetched from any higher level dependencies.Unfortunately, this behavior was broken with the introduction of referencing dependency inputs in version 0.55.4. Currently all the outputs are fetched recursively for all dependency levels, which takes a long time when the dependency graph is complex but in reality only the lowest level dependency output is required for the root module.
Steps To Reproduce
Given below minimum configuration structure, I was able to reproduce the improper behavior.
After applying
module-a
andmodule-b
, I ranterragrunt plan
formodule-c
with version 0.55.3, which gave the following debug logs:Then I ran the same command with the newest Terragrunt 0.67.13, and the debug logs clearly show that outputs of
module-a
were fetched as well, even though they are not required bymodule-c
.Expected behavior
Terragrunt should not fetch dependency outputs recursively, but just for the immediate dependency that is required. Basically the behavior from version 0.55.3 should be restored, but taking into consideration the newer feature of referencing dependency inputs as well.
Nice to haves
Versions
Additional context
We use Azure
remote_state
and dependency graphs as below are not uncommon. This causes the dependency fetching part take several minutes instead of several seconds.