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

history: add error details to history inspect command #2925

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

tonistiigi
Copy link
Member

For failed builds, show source with error location and last logs for vertex that caused the error. When debug mode is on, stacktrace is printed.

docker buildx history inspect m38a1hxgttgm2qcyrjs14yf3j                                                           !10057
Context:	.
Dockerfile:	Dockerfile

Started:	2025-01-17 04:48:42
Duration:	4.1s
Error:		Unknown process "/bin/sh -c apk add foo" did not complete successfully: exit code: 1
Build Steps:	8/10 (0% cached)


Dockerfile:4
--------------------
   2 |     copy Dockerfile .
   3 |     run apk add git
   4 | >>> run apk add foo
   5 |     run apk add vim
   6 |     copy Dockerfile d2
--------------------

 => [4/6] RUN apk add foo:
ERROR: unable to select packages:
  foo (no such package):
    required by: world[foo]

Enable --debug to see stack traces for error
Print build logs: docker buildx history logs m38a1hxgttgm2qcyrjs14yf3j
View build in Docker Desktop: docker-desktop://dashboard/build/priceless_brahmagupta/priceless_brahmagupta0/m38a1hxgttgm2qcyrjs14yf3j

For failed builds, show the source with error location and last
logs for vertex that caused the error. When debug mode is on,
stacktrace is printed.

Signed-off-by: Tonis Tiigi <[email protected]>
@tonistiigi tonistiigi force-pushed the history-inspect-error branch from 2e05415 to 8c27b5c Compare January 17, 2025 05:12
@tonistiigi
Copy link
Member Author

Added 2 additional commits for small fixes to history inspect command.

if err != nil {
return errors.Wrapf(err, "failed to parse vertex digest %s", ve.Vertex.Digest)
}
name, logs, err := loadVertexLogs(ctx, c, rec.Ref, dgst, 16)
Copy link
Member

@crazy-max crazy-max Jan 17, 2025

Choose a reason for hiding this comment

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

Could we have an env var or --verbose flag to remove error log lines limit ? I have a use case for build summary GHA where I need full error logs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be careful about extra fields when we are missing --format atm. If users want more logs they can run the history logs command.

Copy link
Member

Choose a reason for hiding this comment

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

It's not just raw logs but specific build error that we need for the build summary in GHA.

Copy link
Member

Choose a reason for hiding this comment

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

Although maybe 16 lines are enough to understand the issue and they can just look at ci logs

Comment on lines 345 to 351
if len(logs) > 0 {
fmt.Fprintf(dockerCli.Out(), "\n => %s:\n", name)
for _, l := range logs {
fmt.Fprintln(dockerCli.Out(), l)
}
fmt.Fprintln(dockerCli.Out())
}
Copy link
Member

@crazy-max crazy-max Jan 17, 2025

Choose a reason for hiding this comment

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

I would need to parse the output of inspect command for build summary in GHA. Could we have a prefix like > that we are using to print BuildKit config with inspect #2684 and also add a Logs: title?:

Context:        /home/crazy/docker-samba
Dockerfile:     Dockerfile
VCS Repository: https://github.com/crazy-max/docker-samba.git
VCS Revision:   6d24d0cc9d7e604e08a4953c9bf53e30e82c712b
Platform:       linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x

Started:        2024-12-27 15:53:44
Duration:       25.4s
Error:          Unknown process "/bin/sh -c make DESTDIR=/dist install" did not complete successfully: exit code: 2
Build Steps:    45/96 (1% cached)


Dockerfile:21
--------------------
  19 |     COPY patches/wsdd2 /tmp/wsdd2-patches
  20 |     RUN patch -p1 < /tmp/wsdd2-patches/0001-fix-msghdr-initialization.patch
  21 | >>> RUN make DESTDIR=/dist install
  22 |
  23 |     FROM crazymax/alpine-s6:${ALPINE_VERSION}-${S6_VERSION}
--------------------

Logs:
> => [linux/arm/v7 wsdd2 7/7] RUN make DESTDIR=/dist install:
> cc -Wall -Wextra -g -O0   -c -o wsdd2.o wsdd2.c
> wsdd2.c: In function 'open_ep':
> wsdd2.c:305:64: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
>   305 |         struct endpoint *ep = (struct endpoint *) calloc(sizeof(*ep), 1);
>       |                                                                ^
> wsdd2.c:305:64: note: earlier argument should specify number of elements, later size of each element
> wsdd2.c: In function 'netlink_recv':
> wsdd2.c:555:20: error: 'struct msghdr' has no member named '__pad2'
>   555 |                 , .__pad2 = 0
>       |                    ^~~~~~
> wsdd2.c:555:29: warning: excess elements in struct initializer
>   555 |                 , .__pad2 = 0
>       |                             ^
> wsdd2.c:555:29: note: (near initialization for 'msg')
> make: *** [<builtin>: wsdd2.o] Error 1

Enable --debug to see stack traces for error
Print build logs: docker buildx history logs nxhbrt6cw9fws2t4xnnw4ic5h
View build in Docker Desktop: docker-desktop://dashboard/build/builder/builder0/nxhbrt6cw9fws2t4xnnw4ic5h

@tonistiigi tonistiigi merged commit 2ee1562 into docker:master Jan 17, 2025
127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants