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
Add bounds to termHeight when BUILDKIT_TTY_LOG_LINES is set #4767
base: master
Are you sure you want to change the base?
Conversation
Can test the dropped output with |
Needs |
Thanks @jedevc - I'll do that and push a new commit. |
97e2726
to
cdb2cde
Compare
util/progress/progressui/init.go
Outdated
@@ -5,6 +5,7 @@ import ( | |||
"runtime" | |||
"strconv" | |||
|
|||
"github.com/moby/term" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already import github.com/container/console
for this functionality
util/progress/progressui/init.go
Outdated
@@ -41,9 +42,13 @@ func init() { | |||
// Make the terminal height configurable at runtime. | |||
termHeightStr := os.Getenv("BUILDKIT_TTY_LOG_LINES") | |||
if termHeightStr != "" { | |||
fd := uintptr(os.Stdout.Fd()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.Stderr
looks more correct for the progress output.
util/progress/progressui/init.go
Outdated
termHeight = termHeightVal | ||
winSize, err := term.GetWinsize(fd) | ||
if err == nil { | ||
termHeight = max(termHeight, min(termHeightVal, int(winSize.Height)-termHeight-1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this condition should be moved to ttyDisplay.print()
. There you already have the terminal height for correct console (without reading os
pkg in util what may not match the writer) and it also picks up the resizes.
Thanks for the review @tonistiigi! I'll make the changes and resubmit. |
d1a060c
to
42cd82f
Compare
util/progress/progressui/display.go
Outdated
@@ -1056,6 +1056,7 @@ func (disp *ttyDisplay) print(d displayInfo, width, height int, all bool) { | |||
lineCount++ | |||
if j.showTerm { | |||
term := j.vertex.term | |||
termHeight = max(termHeightMin, min(termHeight, height-termHeightMin-1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a new scoped variable, as I think previous computation shouldn't change the calculation for the next round.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point that every round having the same result. termHeight
is used in both print
and update
though, so should it be a package-level variable? Then I'd change it to something like:
const termHeightMin
var termHeightInitial
var termHeight
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure you get what would be the difference between termHeightInitial
and termHeightMin
. If you need another var that sgtm though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, here's what I was thinking:
termHeightMin
is a const (and set to 6).
termHeightInitial
is set to BUILDKIT_TTY_LOG_LINES
if set (otherwise defaults to termHeightMin
).
We then check bounds on termHeightInitial
- if it passes, we set termHeight
to it, otherwise it gets set to the larger of termHeightMin
or height-7
. This way, the computation doesn't depend on the previous value for termHeight
.
BTW I appreciate the many looks as I fumble around on this!
util/progress/progressui/init.go
Outdated
@@ -13,7 +13,8 @@ var colorCancel aec.ANSI | |||
var colorWarning aec.ANSI | |||
var colorError aec.ANSI | |||
|
|||
var termHeight = 6 | |||
var termHeightMin = 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be const
@holzman - Do we still want to advance this? If so, there appear to be some open items ;) |
We should. But I had a question: any objection to adding an additional package-level variable instead of scoping it to the method (since |
e835b55
to
96db1f0
Compare
Sending this back to the drawing board for a bit: I'm managing to crash the display by aggressively resizing the window. |
FWIW, I think the crashes were actually due to a bug in the underlying vt100 module. |
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>
96db1f0
to
3884559
Compare
In order to print tty output, the termHeight for the vt100 module needs to be between 6 and (current window size - 7).
Fixes #4766.