Skip to content

Commit 9598c4c

Browse files
committed
Retry initializing TTY size a bit more
I some cases, for example if there is a heavy load, the initialization of the TTY size would fail. This change makes the cli retry 10 times instead of 5 and we wait incrementally from 10ms to 100ms Relates to #3554 Signed-off-by: Djordje Lukic <[email protected]>
1 parent 6c9eb70 commit 9598c4c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

cli/command/container/tty.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func resizeTty(ctx context.Context, cli command.Cli, id string, isExec bool) err
4545
return resizeTtyTo(ctx, cli.Client(), id, height, width, isExec)
4646
}
4747

48-
// initTtySize is to init the tty's size to the same as the window, if there is an error, it will retry 5 times.
48+
// initTtySize is to init the tty's size to the same as the window, if there is an error, it will retry 10 times.
4949
func initTtySize(ctx context.Context, cli command.Cli, id string, isExec bool, resizeTtyFunc func(ctx context.Context, cli command.Cli, id string, isExec bool) error) {
5050
rttyFunc := resizeTtyFunc
5151
if rttyFunc == nil {
@@ -54,8 +54,8 @@ func initTtySize(ctx context.Context, cli command.Cli, id string, isExec bool, r
5454
if err := rttyFunc(ctx, cli, id, isExec); err != nil {
5555
go func() {
5656
var err error
57-
for retry := 0; retry < 5; retry++ {
58-
time.Sleep(10 * time.Millisecond)
57+
for retry := 0; retry < 10; retry++ {
58+
time.Sleep(time.Duration(retry+1) * 10 * time.Millisecond)
5959
if err = rttyFunc(ctx, cli, id, isExec); err == nil {
6060
break
6161
}

cli/command/container/tty_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ func TestInitTtySizeErrors(t *testing.T) {
2525
ctx := context.Background()
2626
cli := test.NewFakeCli(&fakeClient{containerExecResizeFunc: fakeContainerExecResizeFunc})
2727
initTtySize(ctx, cli, "8mm8nn8tt8bb", true, fakeResizeTtyFunc)
28-
time.Sleep(100 * time.Millisecond)
28+
time.Sleep(750 * time.Millisecond)
2929
assert.Check(t, is.Equal(expectedError, cli.ErrBuffer().String()))
3030
}

0 commit comments

Comments
 (0)