Skip to content

Commit 94d4d0e

Browse files
committed
tmp: Adding some logging to see what symlink experiment usage is causing trouble
1 parent 3e3b5d1 commit 94d4d0e

File tree

10 files changed

+74
-23
lines changed

10 files changed

+74
-23
lines changed

.github/workflows/integration-test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,17 @@ jobs:
150150
setup_scripts:
151151
- .github/scripts/setup/experiment-symlinks.sh
152152

153-
- name: Experiment cas
154-
os: ubuntu
155-
target: ./...
156-
setup_scripts:
157-
- .github/scripts/setup/experiment-cas.sh
153+
# - name: Experiment cas
154+
# os: ubuntu
155+
# target: ./...
156+
# setup_scripts:
157+
# - .github/scripts/setup/experiment-cas.sh
158158

159-
- name: Experiment filter-flag
160-
os: ubuntu
161-
target: ./...
162-
setup_scripts:
163-
- .github/scripts/setup/experiment-filter-flag.sh
159+
# - name: Experiment filter-flag
160+
# os: ubuntu
161+
# target: ./...
162+
# setup_scripts:
163+
# - .github/scripts/setup/experiment-filter-flag.sh
164164
steps:
165165
- name: Checkout code
166166
uses: actions/checkout@v5

cli/commands/run/download_source.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func downloadTerraformSource(
4747
r *report.Report,
4848
) (*options.TerragruntOptions, error) {
4949
walkWithSymlinks := opts.Experiments.Evaluate(experiment.Symlinks)
50+
if walkWithSymlinks {
51+
l.Info("Symlinks experiment enabled. Downloading Terraform source with symlinks.")
52+
}
5053

5154
terraformSource, err := tf.NewSource(l, source, opts.DownloadDir, opts.WorkingDir, walkWithSymlinks)
5255
if err != nil {

config/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ func (cfg *TerragruntConfig) GetRemoteState(l log.Logger, opts *options.Terragru
186186

187187
if sourceURL != "" {
188188
walkWithSymlinks := opts.Experiments.Evaluate(experiment.Symlinks)
189+
if walkWithSymlinks {
190+
l.Info("Symlinks experiment enabled. Walking directory with symlinks.")
191+
}
189192

190193
tfSource, err := tf.NewSource(l, sourceURL, opts.DownloadDir, opts.WorkingDir, walkWithSymlinks)
191194
if err != nil {
@@ -1084,11 +1087,13 @@ func GetDefaultConfigPath(workingDir string) string {
10841087

10851088
// FindConfigFilesInPath returns a list of all Terragrunt config files in the given path or any subfolder of the path. A file is a Terragrunt
10861089
// config file if it has a name as returned by the DefaultConfigPath method
1087-
func FindConfigFilesInPath(rootPath string, opts *options.TerragruntOptions) ([]string, error) {
1090+
func FindConfigFilesInPath(l log.Logger, rootPath string, opts *options.TerragruntOptions) ([]string, error) {
10881091
configFiles := []string{}
10891092

10901093
walkFunc := filepath.Walk
10911094
if opts.Experiments.Evaluate(experiment.Symlinks) {
1095+
l.Info("Symlinks experiment enabled. Walking directory with symlinks.")
1096+
10921097
walkFunc = util.WalkWithSymlinks
10931098
}
10941099

config/config_helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ func getWorkingDir(ctx *ParsingContext, l log.Logger) (string, error) {
615615
}
616616

617617
walkWithSymlinks := ctx.TerragruntOptions.Experiments.Evaluate(experiment.Symlinks)
618+
if walkWithSymlinks {
619+
l.Info("Symlinks experiment enabled. Getting working directory with symlinks.")
620+
}
618621

619622
source, err := tf.NewSource(l, sourceURL, ctx.TerragruntOptions.DownloadDir, ctx.TerragruntOptions.WorkingDir, walkWithSymlinks)
620623
if err != nil {

config/config_test.go

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,11 +1048,13 @@ func TestParseTerragruntJsonConfigTerraformWithMultipleExtraArguments(t *testing
10481048
func TestFindConfigFilesInPathNone(t *testing.T) {
10491049
t.Parallel()
10501050

1051+
l := createLogger()
1052+
10511053
expected := []string{}
10521054
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
10531055
require.NoError(t, err)
10541056

1055-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/none", terragruntOptions)
1057+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/none", terragruntOptions)
10561058

10571059
require.NoError(t, err, "Unexpected error: %v", err)
10581060
assert.Equal(t, expected, actual)
@@ -1061,11 +1063,13 @@ func TestFindConfigFilesInPathNone(t *testing.T) {
10611063
func TestFindConfigFilesInPathOneConfig(t *testing.T) {
10621064
t.Parallel()
10631065

1066+
l := createLogger()
1067+
10641068
expected := []string{"../test/fixtures/config-files/one-config/subdir/terragrunt.hcl"}
10651069
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
10661070
require.NoError(t, err)
10671071

1068-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/one-config", terragruntOptions)
1072+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/one-config", terragruntOptions)
10691073

10701074
require.NoError(t, err, "Unexpected error: %v", err)
10711075
assert.Equal(t, expected, actual)
@@ -1074,11 +1078,13 @@ func TestFindConfigFilesInPathOneConfig(t *testing.T) {
10741078
func TestFindConfigFilesInPathOneJsonConfig(t *testing.T) {
10751079
t.Parallel()
10761080

1081+
l := createLogger()
1082+
10771083
expected := []string{"../test/fixtures/config-files/one-json-config/subdir/terragrunt.hcl.json"}
10781084
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
10791085
require.NoError(t, err)
10801086

1081-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/one-json-config", terragruntOptions)
1087+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/one-json-config", terragruntOptions)
10821088

10831089
require.NoError(t, err, "Unexpected error: %v", err)
10841090
assert.Equal(t, expected, actual)
@@ -1087,6 +1093,8 @@ func TestFindConfigFilesInPathOneJsonConfig(t *testing.T) {
10871093
func TestFindConfigFilesInPathMultipleConfigs(t *testing.T) {
10881094
t.Parallel()
10891095

1096+
l := createLogger()
1097+
10901098
expected := []string{
10911099
"../test/fixtures/config-files/multiple-configs/terragrunt.hcl",
10921100
"../test/fixtures/config-files/multiple-configs/subdir-2/subdir/terragrunt.hcl",
@@ -1095,7 +1103,7 @@ func TestFindConfigFilesInPathMultipleConfigs(t *testing.T) {
10951103
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
10961104
require.NoError(t, err)
10971105

1098-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/multiple-configs", terragruntOptions)
1106+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/multiple-configs", terragruntOptions)
10991107

11001108
require.NoError(t, err, "Unexpected error: %v", err)
11011109
assert.ElementsMatch(t, expected, actual)
@@ -1104,6 +1112,8 @@ func TestFindConfigFilesInPathMultipleConfigs(t *testing.T) {
11041112
func TestFindConfigFilesInPathMultipleJsonConfigs(t *testing.T) {
11051113
t.Parallel()
11061114

1115+
l := createLogger()
1116+
11071117
expected := []string{
11081118
"../test/fixtures/config-files/multiple-json-configs/terragrunt.hcl.json",
11091119
"../test/fixtures/config-files/multiple-json-configs/subdir-2/subdir/terragrunt.hcl.json",
@@ -1112,7 +1122,7 @@ func TestFindConfigFilesInPathMultipleJsonConfigs(t *testing.T) {
11121122
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
11131123
require.NoError(t, err)
11141124

1115-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/multiple-json-configs", terragruntOptions)
1125+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/multiple-json-configs", terragruntOptions)
11161126

11171127
require.NoError(t, err, "Unexpected error: %v", err)
11181128
assert.ElementsMatch(t, expected, actual)
@@ -1121,6 +1131,8 @@ func TestFindConfigFilesInPathMultipleJsonConfigs(t *testing.T) {
11211131
func TestFindConfigFilesInPathMultipleMixedConfigs(t *testing.T) {
11221132
t.Parallel()
11231133

1134+
l := createLogger()
1135+
11241136
expected := []string{
11251137
"../test/fixtures/config-files/multiple-mixed-configs/terragrunt.hcl.json",
11261138
"../test/fixtures/config-files/multiple-mixed-configs/subdir-2/subdir/terragrunt.hcl",
@@ -1129,7 +1141,7 @@ func TestFindConfigFilesInPathMultipleMixedConfigs(t *testing.T) {
11291141
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
11301142
require.NoError(t, err)
11311143

1132-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/multiple-mixed-configs", terragruntOptions)
1144+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/multiple-mixed-configs", terragruntOptions)
11331145

11341146
require.NoError(t, err, "Unexpected error: %v", err)
11351147
assert.ElementsMatch(t, expected, actual)
@@ -1138,13 +1150,15 @@ func TestFindConfigFilesInPathMultipleMixedConfigs(t *testing.T) {
11381150
func TestFindConfigFilesIgnoresTerragruntCache(t *testing.T) {
11391151
t.Parallel()
11401152

1153+
l := createLogger()
1154+
11411155
expected := []string{
11421156
"../test/fixtures/config-files/ignore-cached-config/terragrunt.hcl",
11431157
}
11441158
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
11451159
require.NoError(t, err)
11461160

1147-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/ignore-cached-config", terragruntOptions)
1161+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/ignore-cached-config", terragruntOptions)
11481162

11491163
require.NoError(t, err, "Unexpected error: %v", err)
11501164
assert.Equal(t, expected, actual)
@@ -1153,6 +1167,8 @@ func TestFindConfigFilesIgnoresTerragruntCache(t *testing.T) {
11531167
func TestFindConfigFilesIgnoresTerraformDataDir(t *testing.T) {
11541168
t.Parallel()
11551169

1170+
l := createLogger()
1171+
11561172
expected := []string{
11571173
"../test/fixtures/config-files/ignore-terraform-data-dir/.tf_data/modules/mod/terragrunt.hcl",
11581174
"../test/fixtures/config-files/ignore-terraform-data-dir/subdir/terragrunt.hcl",
@@ -1161,7 +1177,7 @@ func TestFindConfigFilesIgnoresTerraformDataDir(t *testing.T) {
11611177
terragruntOptions, err := options.NewTerragruntOptionsForTest("test")
11621178
require.NoError(t, err)
11631179

1164-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/ignore-terraform-data-dir", terragruntOptions)
1180+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/ignore-terraform-data-dir", terragruntOptions)
11651181

11661182
require.NoError(t, err, "Unexpected error: %v", err)
11671183
assert.ElementsMatch(t, expected, actual)
@@ -1170,6 +1186,8 @@ func TestFindConfigFilesIgnoresTerraformDataDir(t *testing.T) {
11701186
func TestFindConfigFilesIgnoresTerraformDataDirEnv(t *testing.T) {
11711187
t.Parallel()
11721188

1189+
l := createLogger()
1190+
11731191
expected := []string{
11741192
"../test/fixtures/config-files/ignore-terraform-data-dir/subdir/terragrunt.hcl",
11751193
"../test/fixtures/config-files/ignore-terraform-data-dir/subdir/.terraform/modules/mod/terragrunt.hcl",
@@ -1179,7 +1197,7 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnv(t *testing.T) {
11791197

11801198
terragruntOptions.Env["TF_DATA_DIR"] = ".tf_data"
11811199

1182-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/ignore-terraform-data-dir", terragruntOptions)
1200+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/ignore-terraform-data-dir", terragruntOptions)
11831201

11841202
require.NoError(t, err, "Unexpected error: %v", err)
11851203
assert.ElementsMatch(t, expected, actual)
@@ -1188,6 +1206,8 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnv(t *testing.T) {
11881206
func TestFindConfigFilesIgnoresTerraformDataDirEnvPath(t *testing.T) {
11891207
t.Parallel()
11901208

1209+
l := createLogger()
1210+
11911211
expected := []string{
11921212
"../test/fixtures/config-files/ignore-terraform-data-dir/.tf_data/modules/mod/terragrunt.hcl",
11931213
"../test/fixtures/config-files/ignore-terraform-data-dir/subdir/terragrunt.hcl",
@@ -1198,7 +1218,7 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnvPath(t *testing.T) {
11981218

11991219
terragruntOptions.Env["TF_DATA_DIR"] = "subdir/.tf_data"
12001220

1201-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/ignore-terraform-data-dir", terragruntOptions)
1221+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/ignore-terraform-data-dir", terragruntOptions)
12021222

12031223
require.NoError(t, err, "Unexpected error: %v", err)
12041224
assert.ElementsMatch(t, expected, actual)
@@ -1207,6 +1227,8 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnvPath(t *testing.T) {
12071227
func TestFindConfigFilesIgnoresTerraformDataDirEnvRoot(t *testing.T) {
12081228
t.Parallel()
12091229

1230+
l := createLogger()
1231+
12101232
cwd, err := os.Getwd()
12111233
require.NoError(t, err)
12121234

@@ -1216,7 +1238,7 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnvRoot(t *testing.T) {
12161238

12171239
terragruntOptions.Env["TF_DATA_DIR"] = filepath.Join(workingDir, ".tf_data")
12181240

1219-
actual, err := config.FindConfigFilesInPath(workingDir, terragruntOptions)
1241+
actual, err := config.FindConfigFilesInPath(l, workingDir, terragruntOptions)
12201242
require.NoError(t, err, "Unexpected error: %v", err)
12211243

12221244
// Create expected paths using filepath.Join for cross-platform compatibility
@@ -1248,6 +1270,8 @@ func TestFindConfigFilesIgnoresTerraformDataDirEnvRoot(t *testing.T) {
12481270
func TestFindConfigFilesIgnoresDownloadDir(t *testing.T) {
12491271
t.Parallel()
12501272

1273+
l := createLogger()
1274+
12511275
expected := []string{
12521276
"../test/fixtures/config-files/multiple-configs/terragrunt.hcl",
12531277
"../test/fixtures/config-files/multiple-configs/subdir-3/terragrunt.hcl",
@@ -1257,7 +1281,7 @@ func TestFindConfigFilesIgnoresDownloadDir(t *testing.T) {
12571281

12581282
terragruntOptions.DownloadDir = "../test/fixtures/config-files/multiple-configs/subdir-2"
12591283

1260-
actual, err := config.FindConfigFilesInPath("../test/fixtures/config-files/multiple-configs", terragruntOptions)
1284+
actual, err := config.FindConfigFilesInPath(l, "../test/fixtures/config-files/multiple-configs", terragruntOptions)
12611285

12621286
require.NoError(t, err, "Unexpected error: %v", err)
12631287
assert.ElementsMatch(t, expected, actual)

config/dependency.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,9 @@ func terragruntAlreadyInit(l log.Logger, opts *options.TerragruntOptions, config
858858
}
859859
} else {
860860
walkWithSymlinks := opts.Experiments.Evaluate(experiment.Symlinks)
861+
if walkWithSymlinks {
862+
l.Info("Symlinks experiment enabled. Checking if module is already init-ed with symlinks.")
863+
}
861864

862865
terraformSource, err := tf.NewSource(l, sourceURL, opts.DownloadDir, opts.WorkingDir, walkWithSymlinks)
863866
if err != nil {

config/stack.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,10 @@ func processLocals(l log.Logger, parser *ParsingContext, opts *options.Terragrun
10891089
// provided Terragrunt options.
10901090
func listStackFiles(l log.Logger, opts *options.TerragruntOptions, dir string) ([]string, error) {
10911091
walkWithSymlinks := opts.Experiments.Evaluate(experiment.Symlinks)
1092+
if walkWithSymlinks {
1093+
l.Info("Symlinks experiment enabled. Listing stack files with symlinks.")
1094+
}
1095+
10921096
walkFunc := filepath.Walk
10931097

10941098
if walkWithSymlinks {

config/variable.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type ParsedVariable struct {
2828
// ParseVariables - parse variables from tf files.
2929
func ParseVariables(l log.Logger, opts *options.TerragruntOptions, directoryPath string) ([]*ParsedVariable, error) {
3030
walkWithSymlinks := opts.Experiments.Evaluate(experiment.Symlinks)
31+
if walkWithSymlinks {
32+
l.Info("Symlinks experiment enabled. Parsing variables with symlinks.")
33+
}
3134

3235
// list all tf files
3336
tfFiles, err := util.ListTfFiles(directoryPath, walkWithSymlinks)

internal/discovery/discovery.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ func (d *Discovery) walkDirectoryConcurrently(
623623
) error {
624624
walkFn := filepath.WalkDir
625625
if opts.Experiments.Evaluate(experiment.Symlinks) {
626+
l.Info("Symlinks experiment enabled. Walking directory concurrently with symlinks.")
627+
626628
walkFn = util.WalkDirWithSymlinks
627629
}
628630

internal/services/catalog/catalog.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ func (s *catalogServiceImpl) Load(ctx context.Context, l log.Logger) error {
119119

120120
// Evaluate experimental features for symlinks and content-addressable storage.
121121
walkWithSymlinks := s.opts.Experiments.Evaluate(experiment.Symlinks)
122+
if walkWithSymlinks {
123+
l.Info("Symlinks experiment enabled. Loading catalog repo with symlinks.")
124+
}
125+
122126
allowCAS := s.opts.Experiments.Evaluate(experiment.CAS)
123127

124128
var errs []error

0 commit comments

Comments
 (0)