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

#1887 Reduced log level for misleading error logs #1889

Merged
merged 9 commits into from
Oct 28, 2021

Conversation

denis256
Copy link
Member

Reduced log level for misleading error logs

Before:

Call to function "find_in_parent_folders" failed: ParentFileNotFound: Could not find a common.hcl in any of the parent folders of
/raid1/projects-work/g/test-repos/issue-1887/terragrunt.hcl. Cause: Traversed all the way to the root..
ERRO[0000] Encountered error while evaluating locals.    prefix=[/raid1/projects-work/g/test-repos/issue-1887]
WARN[0000] Failed to detect where module is used Error processing module at '/raid1/projects-work/g/test-repos/issue-1887/terragrunt.hcl

After:

Call to function "find_in_parent_folders" failed: ParentFileNotFound: Could not find a common.hcl in any of the parent folders of
/raid1/projects-work/g/test-repos/issue-1887/terragrunt.hcl. Cause: Traversed all the way to the root..

WARN[0000] Failed to detect where module is used Error processing module at '/raid1/projects-work/g/test-repos/issue-1887/terragrunt.hcl'.

Bugfix for: #1887

config/locals.go Outdated Show resolved Hide resolved
@denis256 denis256 marked this pull request as draft October 25, 2021 19:47
@denis256
Copy link
Member Author

$ terragrunt destroy

image

$ terragrunt destroy --terragrunt-log-level debug --terragrunt-debug

image

@denis256 denis256 marked this pull request as ready for review October 26, 2021 11:08
Comment on lines 522 to 527
cfgOptions.LogLevel = terragruntOptions.LogLevel
if terragruntOptions.TerraformCommand == "destroy" {
var hook = NewLogReductionHook()
hook.AddMessage("Encountered error while evaluating locals", logrus.DebugLevel)
cfgOptions.Logger.Logger.AddHook(hook)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the desired behavior is to push all messages while parsing for finding stack to debug level, not just this message. E.g., the Error: Error in function call logs are also noise. Basically, the only log we want is the warning log (WARN: Failed to detect ...).

So maybe the hook we need is ForceLogLevelHook?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle entries like Error: Error in function call had to update DiagnosticTextWriter to write output through logger

@denis256 denis256 requested a review from yorinasub17 October 26, 2021 17:13
Copy link
Contributor

@yorinasub17 yorinasub17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates LGTM! Let me kick off a build now. I'll also do some tests to see what the new outputs look like and if they all look good, we can merge this in!

Copy link
Contributor

@yorinasub17 yorinasub17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the logs look and behave as desired! Once the build passes, I think we can merge this in!

@yorinasub17
Copy link
Contributor

Build passed, so will go ahead and merge this in! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants