126 Commits

Author SHA1 Message Date
Tonis Tiigi
1579c97dac test: stabilize nested progress assertions
Progress reads collapse unread updates by ID, so the raw item count can vary
with scheduling. Assert the final status for each nested writer instead.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 17:01:10 -07:00
Tonis Tiigi
bd3608ddc9 lint: update golangci-lint to v2.12.2
Update golangci-lint and adjust code for new gosec diagnostics. Use
root-scoped filesystem operations where appropriate, preserve explicit
user path behavior for SSH keys, and avoid background contexts in
request-scoped cleanup paths.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-05-14 10:13:15 -07:00
Jonathan A. Sternberg
799749a8fb fix: remove data race in the progress writer
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-04-14 15:05:50 -05:00
Tonis Tiigi
c88c4a7225 progressui: fix panic on very small terminal
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-12 17:10:58 -07:00
Tonis Tiigi
69d3d44145 lint: add unconvert
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:44:01 -07:00
Tonis Tiigi
c6a1dcd6b5 lint: correcting errorlint and some err113 cases
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:22 -07:00
Tonis Tiigi
f1f56c2b77 golangci-lint: v2 upgrade
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:17 -07:00
Tonis Tiigi
f6c142ec23 lint: update some sorting code to newer generics based libs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-20 10:32:02 -07:00
Tonis Tiigi
b5286f8dcb apply x/tools/modernize fixes
Autogenerated with couple of manual patches.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-07 08:18:45 -08:00
Tonis Tiigi
6737deb443 vendor: add go-csvvalue for more efficient CSV parsing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-21 08:05:56 -07:00
Tonis Tiigi
dfc35271ae simplify with maps pkg functions
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 18:33:30 -07:00
Tonis Tiigi
fc936ae3d7 lint: more testifylint fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-10 21:16:51 -07:00
Tõnis Tiigi
843be8670c Merge pull request #4932 from tonistiigi/testifylint-fixes1
lint: fix some testifylint warnings
2024-05-31 07:48:54 -07:00
thompson-shaun
6221b6a63c Merge pull request #4767 from holzman/tty-log-lines-bounds 2024-05-31 10:34:26 -04:00
Burt Holzman
6c2e8b9546 Add bounds to termHeight when BUILDKIT_TTY_LOG_LINES is set
In order to print tty output, the termHeight for the vt100
module needs to be between 6 and (current window size - 7).

Signed-off-by: Burt Holzman <burt@fnal.gov>
2024-05-30 14:08:40 -05:00
Tonis Tiigi
03c7a6d769 lint: fix some testifylint warnings
This does not cover all warning yet but split
into chunks to ease review.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-30 11:32:55 -07:00
Tonis Tiigi
265d18f2e6 lint: enable gocritic
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-15 16:44:38 -07:00
Erik Sipsma
04745a7cc3 progress: fix leak of pipe goroutine from MultiReader
In the case where the context provided to MultiReader.Reader is
cancelled, the writer will be deleted.

Before this, closeWriter was not called in that codepath, when meant
that MultiReader.handle would never see the writer and never close it.
* I don't have an isolated repro, but when running a few hundred of
  Dagger's tests I was seeing several thousand goroutines blocked on
  waiting for the progress pipe's context to be done.

Now, we just call closeWriter when it gets deleted so that the pipe's
goroutine doesn't leak.
* After this change, those thousands of leaked goroutines are entirely
  gone.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2024-05-03 19:40:17 -07:00
Justin Chadwell
08180a7742 Merge pull request #4770 from felixfontein/rawjson
rawjson output: remove indent so that every message is printed in one line
2024-05-01 13:33:21 +01:00
Tonis Tiigi
1f9988911f lint: unusedparams fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:16 -07:00
Felix Fontein
3fb3b0781b Remove indent so that every rawjson message is printed in one line.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-03-17 21:18:21 +01:00
Justin Chadwell
7aee2929ee progress: add panic for multiwriter cycles
Previously, if this case occured, we would deadlock, so as to make this
case more easily identifiable and debuggable, we should panic instead.
Potentially, we could also just *skip* this case, but given that this is
an internal logical error that should not occur, it would be better to
identify this.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-17 14:14:40 +00:00
Tonis Tiigi
8a2a3e83ec replace context.WithCancel with WithCancelCause
Keep stack traces for cancellation errors where possible.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-12-06 22:15:06 -08:00
Tonis Tiigi
e1da8b7f82 solver: fix printing progress messages after merged edges
When different LLB vertexes (eg. parallel requests referencing
local sources from different sessions) generate same cache keys
during solve they are merged together into a single operation.

Currently, when this happened the progress for the vertex that
was dropped got lost. This fixes this case by adding the
progressWriter of the redirected vertex as a target to the
source one.

This should also work with multiple levels of merged edges,
just multiple nested multiwriters as well.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-10-23 15:02:53 -07:00
Burt Holzman
2677a22857 Make output window configurable: BUILDKIT_TTY_LOG_LINES
The output window was previously hard-coded to a height of 6;
this patch makes it configurable at run-time by setting the
BUILDKIT_TTY_LOG_LINES environment variable.

Signed-off-by: Burt Holzman <burt@fnal.gov>
2023-09-28 13:43:53 -05:00
Jonathan A. Sternberg
f53bc88c86 progressui: modify NewDisplay to accept io.Writer instead of console.File
The original intention of accepting `console.File` was that the current
uses of this function in the codebase were always files and it seemed
helpful to restrict the API to `console.File` to aid developers into
passing the correct output.

There are circumstances outside of the codebase where the `io.Writer`
versions are used so `NewDisplay` has now been adapted to take an
`io.Writer` to allow for those cases more easily.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2023-09-12 14:39:01 -05:00
Justin Chadwell
d9defe0d1c progress: add new quiet display mode
This display mode silently discards all output.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-09-07 12:25:18 +01:00
Tibor Vass
d59eee2985 util/progress: silence go test -race
Without this commit, `go test -race ./util/progress` sees a race due to the
shadowed `ctx` variable.

```
==================
WARNING: DATA RACE
Read at 0x00c000206040 by goroutine 25:
  github.com/moby/buildkit/util/progress.TestProgress.func1()
      github.com/moby/buildkit/util/progress/progress_test.go:25 +0x44
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x6c

Previous write at 0x00c000206040 by goroutine 6:
  github.com/moby/buildkit/util/progress.TestProgress()
      github.com/moby/buildkit/util/progress/progress_test.go:28 +0x4a0
  testing.tRunner()
      testing/testing.go:1576 +0x188
  testing.(*T).Run.func1()
      testing/testing.go:1629 +0x40

Goroutine 25 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      golang.org/x/sync@v0.1.0/errgroup/errgroup.go:72 +0x10c
  github.com/moby/buildkit/util/progress.TestProgress()
      github.com/moby/buildkit/util/progress/progress_test.go:24 +0x360
  testing.tRunner()
      testing/testing.go:1576 +0x188
  testing.(*T).Run.func1()
      testing/testing.go:1629 +0x40

Goroutine 6 (running) created at:
  testing.(*T).Run()
      testing/testing.go:1629 +0x5e4
  testing.runTests.func1()
      testing/testing.go:2036 +0x80
  testing.tRunner()
      testing/testing.go:1576 +0x188
  testing.runTests()
      testing/testing.go:2034 +0x700
  testing.(*M).Run()
      testing/testing.go:1906 +0x950
  main.main()
      _testmain.go:49 +0x300
==================
==================
WARNING: DATA RACE
Read at 0x00c000202390 by goroutine 26:
  context.(*valueCtx).Done()
      <autogenerated>:1 +0x34
  github.com/moby/buildkit/util/progress.(*progressReader).Read.func1()
      github.com/moby/buildkit/util/progress/progress.go:126 +0xac

Previous write at 0x00c000202390 by goroutine 6:
  context.WithValue()
      context/context.go:593 +0xac
  github.com/moby/buildkit/util/progress.FromContext.func1()
      github.com/moby/buildkit/util/progress/progress.go:42 +0x168
  github.com/moby/buildkit/util/progress.NewFromContext()
      github.com/moby/buildkit/util/progress/progress.go:51 +0x60
  github.com/moby/buildkit/util/progress.TestProgress()
      github.com/moby/buildkit/util/progress/progress_test.go:28 +0x488
  testing.tRunner()
      testing/testing.go:1576 +0x188
  testing.(*T).Run.func1()
      testing/testing.go:1629 +0x40

Goroutine 26 (running) created at:
  github.com/moby/buildkit/util/progress.(*progressReader).Read()
      github.com/moby/buildkit/util/progress/progress.go:120 +0x15c
  github.com/moby/buildkit/util/progress.saveProgress()
      github.com/moby/buildkit/util/progress/progress_test.go:125 +0x48
  github.com/moby/buildkit/util/progress.TestProgress.func1()
      github.com/moby/buildkit/util/progress/progress_test.go:25 +0x60
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x6c

Goroutine 6 (running) created at:
  testing.(*T).Run()
      testing/testing.go:1629 +0x5e4
  testing.runTests.func1()
      testing/testing.go:2036 +0x80
  testing.tRunner()
      testing/testing.go:1576 +0x188
  testing.runTests()
      testing/testing.go:2034 +0x700
  testing.(*M).Run()
      testing/testing.go:1906 +0x950
  main.main()
      _testmain.go:49 +0x300
==================
--- FAIL: TestProgressNested (0.07s)
    testing.go:1446: race detected during execution of test
--- FAIL: TestProgress (0.10s)
    testing.go:1446: race detected during execution of test
FAIL
FAIL    github.com/moby/buildkit/util/progress  0.112s
FAIL
```

Signed-off-by: Tibor Vass <teabee89@gmail.com>
2023-08-25 10:16:00 -07:00
Jonathan A. Sternberg
37131781d7 progressui: adds a json output that shows raw events for the solver status
This adds an additional display output for the progress indicator to
support a json output. It refators the progressui package a bit to add a
new method that takes in a `SolveStatusDisplay`. This
`SolveStatusDisplay` can be created by the user using `NewDisplay` with
the various modes as input parameters.

The json output will print the raw events as JSON blobs. It will not
throttle the messages or limit the display. It is meant as a pure raw
marshaling of the underlying event stream.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2023-08-24 16:45:58 -05:00
Jonathan A. Sternberg
4c83fcf365 Avoid unnecessary map allocation when writing progress
`MultiWriter` would create an unnecessary map allocation when the
`Write` method was used. The `Write` method would create a progress
object with the meta field initialized to the meta field of the writer
itself. It then invoked its own `WriteRawProgress` method which would
see two maps with the metadata and erroneously believe that they were
different and needed to be merged into a single metadata map.

Since this map is initialized with the metadata of the writer before
`WriteRawProgress` is invoked, this merge was unnecessary and could add
a lot of unnecessary memory allocations during a build.

This changes the `MultiWriter.Write` method to invoke the private
`writeRawProgress` which performs the actual write and avoids the
metadata merge.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2023-08-07 17:00:48 -05:00
Justin Chadwell
957d52f018 progress: don't modify ResetTime inputs
No other parts of the progress rendering modify the inputs, so we should
avoid this as well.

This actually fixes an edge case in pushWithMoby which writes the same
VertexStatus multiple times, modifying the timestamps and similar.
However, if the operation takes long enough the small time difference
can accumulate, and move the Start time far into the past.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-07-25 09:47:53 +01:00
Tonis Tiigi
aae870584e progressui: fix index printing on partial rows
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 18:25:48 -07:00
Tonis Tiigi
ca944127c4 progressui: fix possible zero prefix numbers in logs
Prefix numbers should only be assigned before printing,
not when receiving data.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-03 15:39:48 -07:00
coryb
a8aa7b200c use bklog.G(ctx) instead of logrus directly
Signed-off-by: coryb <cbennett@netflix.com>
2023-03-15 12:07:44 -07:00
CrazyMax
6b8fbed01e progress: solve status description
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-02-13 15:55:01 +01:00
Justin Chadwell
0390348824 progress: keep color enabled with NO_COLOR empty
The NO_COLOR specification says that color should be disabled if
NO_COLOR is set *and not empty*.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-01-31 10:16:32 +00:00
Tonis Tiigi
be6e1cf55e history api: support for logs of completed builds
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Tonis Tiigi
dbee61670d add build history APIs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-22 23:59:33 -08:00
Sebastiaan van Stijn
ebc87234b5 util/progress: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-19 22:56:05 +02:00
Tianon Gravi
2602415198 Fix no-newline-at-end-of-RUN output issue
This edge case was already handled for `CANCELED` or `ERROR`, but not `DONE` (or `CACHED`, which shouldn't have logs, but 🤷).

Before:

```console
$ docker buildx build --progress=plain --no-cache - <<<$'FROM bash\nRUN echo -n no newline'
...
#5 [2/2] RUN echo -n no newline
#5 0.268 no newline#5 DONE 0.3s
...
```

After:

```console
$ docker buildx build --progress=plain --no-cache - <<<$'FROM bash\nRUN echo -n no newline'
...
#5 [2/2] RUN echo -n no newline
#5 0.268 no newline
#5 DONE 0.3s
...
```

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2022-08-30 15:31:56 -07:00
CrazyMax
00ee28175c progress: mutualize OneOff helper
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-08 12:52:59 +02:00
Sean P. Kane
509444fc35 Add 'hasWarning' comment
Signed-off-by: Sean P. Kane <spkane00@gmail.com>
2022-07-20 15:15:34 -07:00
Sean P. Kane
cd48499751 Configurable terminal colors
Signed-off-by: Sean P. Kane <spkane00@gmail.com>
2022-07-20 09:03:39 -07:00
David Gageot
1245e43085 Enable gosimple linter
Signed-off-by: David Gageot <david.gageot@doctolib.com>
2022-04-23 23:57:16 +02:00
Erik Sipsma
5e573f1cfe progressui: fix printing of hidden vertexes.
The plain progress has a loop that iterates over each vertex the trace
knows about (rather than just the updated ones). Before this, that loop
was not checking to see if a vertex was supposed to be skipped due to
being in a group or due to being hidden.

This resulted in vertexes being printed unnecessarily. It also led to a
rare case where a vertex with nil lastBlockTime could be set to the
'current' field, which could then result in a nil pointer exception.

The update here just adds the appropriate checks to the loop.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-04-01 11:33:08 -07:00
Erik Sipsma
87bfcc0e65 progress: Update printer to support intervals.
The previous updates for start/stop intervals only updated the tty
display. Now, corresponding changes have been made to the plain progress
printer too.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-03-04 20:09:26 -08:00
Tõnis Tiigi
2dfbe317c9 Merge pull request #2689 from tonistiigi/active-status
progressui: handle active statuses for completed vertex
2022-03-01 18:36:03 -08:00
Tonis Tiigi
d75a79eacc progressui: handle case where active statuses appear completed vertex
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-02-28 23:40:45 -08:00
Tonis Tiigi
379ac1b1f7 progressui: fix possible out of order indexing on plain mode
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-02-28 23:37:51 -08:00
Erik Sipsma
cc1499e6d9 Add support for weak ProgressGroup membership.
A ProgressGroup will now only be displayed if a vertex member marked as
non-weak has started.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-02-25 10:24:15 -08:00