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

progress: disable truncating by default when using --progress=plain #1435

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

thaJeztah
Copy link
Member

fixes #1412

Currently, docker build --progress=plain truncates output, which makes it
difficult to debug problems during build (the step that failed may not be the
cause of the failure).

For example, in the following build, the output of the RUN echo ... is truncated:

DOCKER_BUILDKIT=1 docker build --no-cache --progress=plain -t foo -<<EOF
FROM busybox
RUN echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ut lorem nec leo euismod vestibulum. Donec tortor nisl, iaculis at vehicula vel, interdum eu orci. Integer velit lacus, congue id magna eu, mollis accumsan augue. Aliquam non venenatis risus, eu posuere libero. Vestibulum ante ipsum primis in faucibus orci luctus." > /somewhere
RUN echo "something went wrong"; exit 1
EOF

#5 [2/3] RUN echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit....
#5 DONE 0.2s

#6 [3/3] RUN echo "something went wrong"; exit 1
#6 0.211 something went wrong
#6 ERROR: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully
------
 > [3/3] RUN echo "something went wrong"; exit 1:
------
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully

While there is an existing PROGRESS_NO_TRUNC environment variable, I think that
this should be the default if the user opted to use --progress=plain (or in
situations where no TTY is attached, which could be in CI).

This patch changes the default to disable truncating in those situations, but
allowing users to opt-out by setting PROGRESS_NO_TRUNC=0

With this change the same build looks like this:

#5 [2/3] RUN echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ut lorem nec leo euismod vestibulum. Donec tortor nisl, iaculis at vehicula vel, interdum eu orci. Integer velit lacus, congue id magna eu, mollis accumsan augue. Aliquam non venenatis risus, eu posuere libero. Vestibulum ante ipsum primis in faucibus orci luctus." > /somewhere
#5 sha256:b2f0f47d63911ee55e7cf17c81007310e28190b5be84aa1a7869ba90786d5cee
#5 DONE 0.2s

#6 [3/3] RUN echo "something went wrong"; exit 1
#6 sha256:c037b34bb998ae7d30572b489286da14df87e1478adf6d0c5c71c79b84b11bcc
#6 0.293 something went wrong
#6 ERROR: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully
------
 > [3/3] RUN echo "something went wrong"; exit 1:
------
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully

Currently, `docker build --progress=plain` truncates output, which makes it
difficult to debug problems during build (the step that failed may not be the
cause of the failure).

For example, in the following build, the output of the `RUN echo ...` is truncated:

    DOCKER_BUILDKIT=1 docker build --no-cache --progress=plain -t foo -<<EOF
    FROM busybox
    RUN echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ut lorem nec leo euismod vestibulum. Donec tortor nisl, iaculis at vehicula vel, interdum eu orci. Integer velit lacus, congue id magna eu, mollis accumsan augue. Aliquam non venenatis risus, eu posuere libero. Vestibulum ante ipsum primis in faucibus orci luctus." > /somewhere
    RUN echo "something went wrong"; exit 1
    EOF

    #5 [2/3] RUN echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit....
    #5 DONE 0.2s

    #6 [3/3] RUN echo "something went wrong"; exit 1
    #6 0.211 something went wrong
    #6 ERROR: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully
    ------
     > [3/3] RUN echo "something went wrong"; exit 1:
    ------
    failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully

While there is an existing `PROGRESS_NO_TRUNC` environment variable, I think that
this should be the default if the user opted to use `--progress=plain` (or in
situations where no TTY is attached, which could be in CI).

This patch changes the default to disable truncating in those situations, but
allowing users to opt-out by setting `PROGRESS_NO_TRUNC=0`

With this change the same build looks like this:

    #5 [2/3] RUN echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ut lorem nec leo euismod vestibulum. Donec tortor nisl, iaculis at vehicula vel, interdum eu orci. Integer velit lacus, congue id magna eu, mollis accumsan augue. Aliquam non venenatis risus, eu posuere libero. Vestibulum ante ipsum primis in faucibus orci luctus." > /somewhere
    #5 sha256:b2f0f47d63911ee55e7cf17c81007310e28190b5be84aa1a7869ba90786d5cee
    #5 DONE 0.2s

    #6 [3/3] RUN echo "something went wrong"; exit 1
    #6 sha256:c037b34bb998ae7d30572b489286da14df87e1478adf6d0c5c71c79b84b11bcc
    #6 0.293 something went wrong
    #6 ERROR: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully
    ------
     > [3/3] RUN echo "something went wrong"; exit 1:
    ------
    failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c echo "something went wrong"; exit 1]: runc did not terminate sucessfully

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@tonistiigi
Copy link
Member

The idea behind the truncation even on plain mode was that the prefix numbers stay aligned. Do you have screenshots on how this looks compared to old. There is also the ... case when parallel blocks switch. Maybe that case should remain truncated as you already have the full line once or maybe that is even more confusing.

@thaJeztah
Copy link
Member Author

Here's two screenshots (I used PROGRESS_NO_TRUNC=1 to mimic the output as I didn't have a docker build with this change, but the output should be the same;

Before:

Screenshot 2020-04-15 at 15 36 45

After:

Screenshot 2020-04-15 at 15 37 31

The idea behind the truncation even on plain mode was that the prefix numbers stay aligned

Do you think we should "hard" wrap the lines and align with the prefix number?

@tonistiigi
Copy link
Member

Do you think we should "hard" wrap the lines and align with the prefix number?

This isn't possible without knowing the actual screen width. And if we are on tty then this view isn't shown anyway by default.

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.

--progress plain results in truncated output width
3 participants