-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[NO TESTS NEEDED] Fix swapped dimensions from terminal.GetSize #9782
[NO TESTS NEEDED] Fix swapped dimensions from terminal.GetSize #9782
Conversation
Seems to fix it: $ resize
COLUMNS=120;
LINES=40;
export COLUMNS LINES;
$ stty size
40 120
$ ./bin/podman run -it fedora stty size
40 120
$ ./bin/podman system service --timeout=0 &
$ ./bin/podman-remote run -it fedora stty size
40 120 |
I'm guessing that @rhatdan's IRC ping was for this PR. In case you need a test: @test "foo" {
pty=$PODMAN_TMPDIR/mypty
dummy=$PODMAN_TMPDIR/dummy
# Create a pty. Run under 'timeout' because BATS reaps child processes
# and if we exit before killing socat, bats will hang forever.
timeout 10 socat PTY,link=$pty,raw,echo=0,waitslave $dummy &
socat_pid=$!
# Wait for pty
retries=5
while [[ ! -e $pty ]]; do
retries=$(( retries - 1 ))
if [[ $retries -eq 0 ]]; then
die "Timed out waiting for $pty"
fi
sleep 0.5
done
# Set the pty to a random size ...
rows=$(( RANDOM % 60 ))
cols=$(( RANDOM % 60 ))
stty rows $rows columns $cols <$pty
# ...and make sure stty under podman reads that.
run_podman run --rm -it $IMAGE stty size <$pty
size=$output
kill $socat_pid
is "$output" "$rows $cols" "stty under podman reads the correct dimensions"
} |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: afbjorklund, mheon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
That's why it was not simple ;-) |
Somewhere in Thank you! |
I experimented with a couple of tests
Or in podman system tests.
This issue here is that there is no |
I'm not entirely sure my test is useful: first, it passes on podman even without your PR (a good test should never pass prior to the fix in question). Second, IIUC your code handles SIGWINCH? If so, it'll be necessary to create the pty, start podman (presumably with -d), |
I think I will await your suggestions on testing, and settle for the manual verification for now. |
Other tests aren't looking hip. |
I would prefer to get this fix in ASAP, do not want to miss the podman 3.1 window, and work on the tests separately if necessary. |
The code change worked OK in manual testing, flipped the rows and columns back to normal again. BEFORE (v3.1)
AFTER
|
@afbjorklund Rebase and repush. |
For posterity, I was never able to get this to work. This is my final attempt: @test "podman handles SIGWINCH" {
pty=$PODMAN_TMPDIR/mypty
dummy=$PODMAN_TMPDIR/dummy
# Create a pty. Run under 'timeout' because BATS reaps child processes
# and if we exit before killing socat, bats will hang forever.
timeout 10 socat PTY,link=$pty,raw,echo=0 PTY,link=$dummy,raw,echo=0 &
socat_pid=$!
# Wait for pty
retries=5
while [[ ! -e $pty ]]; do
retries=$(( retries - 1 ))
if [[ $retries -eq 0 ]]; then
die "Timed out waiting for $pty"
fi
sleep 0.5
done
# Set the pty to a fixed size
stty rows 10 columns 10 <$pty
# Set the pty to a random size. Make rows/columns odd/even, to guarantee
# that they can never be the same
rows=$(( 15 + RANDOM % 60 | 1 ))
cols=$(( 15 + RANDOM % 60 & 126 ))
( sleep 2; wait_for_ready mystty; stty rows $rows columns $cols <$pty; run_podman kill -sWINCH mystty; run_podman exec mystty touch /stop ) &
# ...and make sure stty under podman reads that.
run_podman run --rm -it --name mystty $IMAGE sh -c \
'stty size;echo READY;retries=100;while [ ! -e /stop -a $retries -gt 0 ]; do sleep 0.1; retries=$(($retries - 1));done;stty size' <$pty
kill $socat_pid
is "${lines[0]}" "10 10" "stty before sigwinch"
is "${lines[2]}" "$rows $cols" "stty under podman reads the correct dimensions"
} Failure: the final |
I had not understood that this was podman-remote. @afbjorklund please save this as # -*- bats -*-
#
# tests that might be especially failure-prone in podman-remote
#
load helpers
@test "podman detects correct tty size" {
pty=$PODMAN_TMPDIR/mypty
dummy=$PODMAN_TMPDIR/dummy
# Create a pty. Run under 'timeout' because BATS reaps child processes
# and if we exit before killing socat, bats will hang forever.
timeout 10 socat PTY,link=$pty,raw,echo=0 PTY,link=$dummy,raw,echo=0 &
socat_pid=$!
# Wait for pty
retries=5
while [[ ! -e $pty ]]; do
retries=$(( retries - 1 ))
if [[ $retries -eq 0 ]]; then
die "Timed out waiting for $pty"
fi
sleep 0.5
done
# Set the pty to a random size. Make rows/columns odd/even, to guarantee
# that they can never be the same
rows=$(( 15 + RANDOM % 60 | 1 ))
cols=$(( 15 + RANDOM % 60 & 126 ))
stty rows $rows cols $cols <$pty
# ...and make sure stty under podman reads that.
# FIXME: 'sleep 1' is needed for podman-remote; without it, there's
# a race condition resulting in the following warning:
# WARN[0000] failed to resize TTY: container "xx" in wrong state "stopped"
# (also "created")
run_podman run -it --name mystty $IMAGE sh -c 'sleep 1;stty size' <$pty
kill $socat_pid
is "$output" "$rows $cols" "stty under podman reads the correct dimensions"
} |
Seeing no activity here, I've submitted #9818 to add a system test. @afbjorklund if you're still working on this, please just rebase and re-push, don't bother adding tests. The re-push will pick up the modified subject, and will then not enforce needing tests. If you read this after #9818 merges, then please rebase, remove the |
Signed-off-by: Anders F Björklund <[email protected]>
a2b4c3b
to
826c228
Compare
/lgtm |
Closes #9756