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

Consolidate repetitive warning messages #23425

Merged
merged 2 commits into from
Nov 19, 2019

Conversation

apparentlymart
Copy link
Contributor

Some of our warning messages are produced in response to the use of deprecated language constructs that might be used many times across a whole configuration, and so the resulting warnings can easily overwhelm the other parts of Terraform's output from commands like terraform plan.

As a compromise, we'll detect when the diagnostics includes more than two warnings with the same summary text and consolidate the third and any further warnings into a single count of additional warnings at the end of the second warning message, like this:

Warning: Interpolation-only expressions are deprecated

  on cli-consolidate-warnings.tf line 7, in resource "null_resource" "b":
   7:   triggers = "${map("a", "b")}"

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

(and 4 more similar warnings elsewhere)

This is intended to strike a compromise between making sure these warnings remain visible but avoiding them distracting too much from other output that appears alongside them. This fixes #23406.

This detects when there are many warning diagnostics with the same summary
and consolidates some of them together into a single diagnostic in order
to make the resulting output less overwhelming when presented in CLI
output where other information is competing for attention with the
warnings.

This is not yet used anywhere. Usage of it will follow in a subsequent
commit.
Some of our warnings are produced in response to particular configuration
constructs which might appear many times across a Terraform configuration.
To avoid the warning output dwarfing all of the other output, we'll use
ConsolidateWarnings to limit each distinct warning summary to appear at
most twice, and annotate the final one in the sequence with an additional
paragraph noting that some number of them have been hidden.

This is intended as a compromise to ensure that these warnings are still
seen and noted but to help ensure that we won't produce so many of them
as to distract from other output that appears alongside them.

This applies only to warnings relating to specific configuration ranges;
errors will continue to be shown individually, and sourceless warnings
(which are rare in Terraform today) will likewise remain ungrouped because
they are less likely to be repeating the same statement about different
instances of the same problem throughout the configuration.
@apparentlymart apparentlymart requested a review from a team November 19, 2019 22:07
@apparentlymart apparentlymart self-assigned this Nov 19, 2019
@ghost ghost added the sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK label Nov 19, 2019
@apparentlymart apparentlymart merged commit 7081c26 into master Nov 19, 2019
@apparentlymart apparentlymart deleted the f-cli-consolidate-warnings branch November 19, 2019 23:36
@apparentlymart apparentlymart added this to the v0.12.17 milestone Nov 20, 2019
@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli enhancement sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flag or env var for quieting syntax deprecation warnings
2 participants