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

Updates to warnings handling #2498

Merged
merged 6 commits into from
Dec 15, 2021
Merged

Conversation

tonistiigi
Copy link
Member

This PR extends #2482 with:

  • support for sourcemaps
  • connect Dockerfile parser warnings
  • show warnings with progressui
  • allow short & detail message in a warning

@tonistiigi
Copy link
Member Author

Some open questions/follow-ups:

  • Currently, every warning includes a full source definition that is mostly identical. We could try to link a source of warning to the source of another to save some space. But doesn't look very clean.
  • Should we add even more structure to the "detail" field. Eg. URL, or category?
  • When doing multiple builds together (eg. buildx bake) same warnings can appear multiple times. Is there a better way to dedupe them than to just do a string-based match?

warnings = append(warnings, "[WARNING]: Empty continuation line found in:\n "+line)
warnings = append(warnings, Warning{
Short: "Empty continuation line found in: " + line,
Detail: "Empty continuation lines will become errors in a future release. https://github.com/moby/moby/pull/33719",
Copy link
Member Author

Choose a reason for hiding this comment

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

@thaJeztah Is this actually marked as deprecated somewhere. Can't find it.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm.. good one; we should at least have it documented in https://docs.docker.com/engine/deprecated/ (looks like we don't), with more discussion in moby/moby#29005.

I think we decided to not remove it (at least for the time being), but to make the warning a bit more scary. Will have to dig those discussions though.

@@ -138,7 +138,10 @@ message VertexLog {
message VertexWarning {
string vertex = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false];
int64 level = 2;
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of level? Is it a threshold controlling how severe a warning must be?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is currently unused though but is propagated to the client if the frontend sets it.

@crazy-max
Copy link
Member

Should we add even more structure to the "detail" field. Eg. URL, or category?

Maybe detail could be a "BuildKit ID" like BK0001 that would be linked to an appendix page https://github.com/moby/buildkit/blob/v0.10.0/docs/warns.md#BK0001 that would provide extra info like some linters do: https://github.com/hadolint/hadolint/wiki/DL3000? The prefix ID could be DF for Dockerfile frontend and BK for BuildKit internals?

@tonistiigi
Copy link
Member Author

@crazy-max At least initially I think all warnings will be from frontend, so defined in dockerfile in our case. I can add separate fields for URL (and code?) if that is desirable and we have ideas how to show them separately on cli. Currently, they are expected to just be inside "detail". I don't want to force some "automatic URLs based on code". If at all that should be on the client side, and other frontends may follow different logic.

@crazy-max
Copy link
Member

@tonistiigi Yes we can begin with frontend and let it decide how detail is defined. URL sgtm but I think it should be mutually exclusive with detail.

@tonistiigi
Copy link
Member Author

Updated with following changes:

  • detail is now an array, eg client can show it either in paragraphs or separate lines.
  • URL is a separate field

Detail is now an array and URL is a separate field.

Signed-off-by: Tonis Tiigi <[email protected]>
@@ -125,6 +125,11 @@ func (p *textMux) printVtx(t *trace, dgst digest.Digest) {
}
v.statusUpdates = map[string]struct{}{}

for _, w := range v.warnings[v.warningIdx:] {
fmt.Fprintf(p.w, "#%d WARN: %s\n", v.index, w.Short)
Copy link
Member

Choose a reason for hiding this comment

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

Do you have an output example in progress ui (asciinema)? Also detail and url are not displayed in progress atm right? Are you thinking of displaying them only in debug mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this just prints the (short) warning message under the vertex like a regular log from a process. The detail/url etc would need to be handled outside of the progress printing. The DisplaySolveStatus https://github.com/moby/buildkit/pull/2498/files#diff-c500feee78b97c9eba6731bee138b3d93ee24cf99f89733d1326b4f4d23e05cfR24 returns the list of all warnings after progress completes so whatever invoked it can do additional processing.

@tonistiigi tonistiigi merged commit 76234fa into moby:master Dec 15, 2021
@crazy-max crazy-max added this to the v0.10.0 milestone Feb 4, 2022
@crazy-max crazy-max mentioned this pull request Feb 4, 2023
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.

4 participants