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

podman client reverses tty rows/colums #9756

Closed
oblutak opened this issue Mar 18, 2021 · 11 comments · Fixed by #9782
Closed

podman client reverses tty rows/colums #9756

oblutak opened this issue Mar 18, 2021 · 11 comments · Fixed by #9782
Assignees
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@oblutak
Copy link

oblutak commented Mar 18, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description
Using podman client on MacOS, the terminal window is sized 17 rows and 364 columns. When connecting to container in interactive shell, the tty is set for 364 rows and 17 colums

Steps to reproduce the issue:

  1. stty size (on Mac)
  2. podman exec -it container_id bash
  3. stty size

Describe the results you received:
364 17

Describe the results you expected:
17 364

Additional information you deem important (e.g. issue happens only occasionally):
I am a container and podman newbie....

Output of podman version:

$ podman version
Client:
Version:      3.0.1
API Version:  3.0.0
Go Version:   go1.15.8
Built:        Sat Feb 20 01:11:38 2021
OS/Arch:      darwin/amd64

Server:
Version:      3.0.0-dev
API Version:  2.0.0
Go Version:   go1.15.7
Built:        Tue Feb  2 17:06:33 2021
OS/Arch:      linux/amd64

Output of podman info --debug:

$ podman info --debug
host:
  arch: amd64
  buildahVersion: 1.19.2
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.25-1.module_el8.4.0+673+eabfc99d.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.25, commit: 897f4ebd69b9e9c725621fabf1d7c918ef635a68'
  cpus: 1
  distribution:
    distribution: '"centos"'
    version: "8"
  eventLogger: file
  hostname: xx-coder
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 4.18.0-277.el8.x86_64
  linkmode: dynamic
  memFree: 428089344
  memTotal: 1905061888
  ociRuntime:
    name: crun
    package: crun-0.17-1.module_el8.4.0+673+eabfc99d.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.17
      commit: 0e9229ae34caaebcb86f1fde18de3acaf18c6d9a
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  security:
    apparmorEnabled: false
    capabilities: CAP_NET_RAW,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    selinuxEnabled: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.8-1.module_el8.4.0+641+6116a774.x86_64
    version: |-
      slirp4netns version 1.1.8
      commit: d361001f495417b880f20329121e3aa431a8f90f
      libslirp: 4.3.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.1
  swapFree: 0
  swapTotal: 0
  uptime: 148h 51m 59.08s (Approximately 6.17 days)
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /home/centos/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 1
    stopped: 1
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: fuse-overlayfs-1.4.0-2.module_el8.4.0+673+eabfc99d.x86_64
      Version: |-
        fusermount3 version: 3.2.1
        fuse-overlayfs: version 1.4
        FUSE library version 3.2.1
        using FUSE kernel interface version 7.26
  graphRoot: /home/centos/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 5
  runRoot: /run/user/1000/containers
  volumePath: /home/centos/.local/share/containers/storage/volumes
version:
  APIVersion: 3.0.0
  Built: 1612303593
  BuiltTime: Tue Feb  2 17:06:33 2021
  GitCommit: ""
  GoVersion: go1.15.7
  OsArch: linux/amd64
  Version: 3.0.0-dev

Package info (e.g. output of rpm -q podman or apt list podman):

podman-3.0.0-0.33rc2.module_el8.4.0+673+eabfc99d.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

I believe these are the latest available to me. Podman newbie and did not review all of troubleshooting guide.
Using crun as runtime.

Additional environment details (AWS, VirtualBox, physical, etc.):
Linux/centos is VM in private OpenStack

@afbjorklund
Copy link
Contributor

Easy enough to reproduce:

$ podman run -it fedora stty size
34 115
$ systemctl start --user podman.socket
$ podman-remote run -it fedora stty size
115 34

@afbjorklund
Copy link
Contributor

45a7e72

                case <-winChange:
                        h, w, err := terminal.GetSize(int(file.Fd()))
                        if err != nil {
                                logrus.Warnf("failed to obtain TTY size: %v", err)
                        }

package terminal // import "golang.org/x/crypto/ssh/terminal"

func GetSize(fd int) (width, height int, err error)
    GetSize returns the dimensions of the given terminal.

@Luap99
Copy link
Member

Luap99 commented Mar 19, 2021

@oblutak @afbjorklund Do you want to open a PR to fix it?

@Luap99 Luap99 added the Good First Issue This issue would be a good issue for a first time contributor to undertake. label Mar 19, 2021
@afbjorklund
Copy link
Contributor

afbjorklund commented Mar 19, 2021

Do you want to open a PR to fix it?

PR seems easy, but most likely it needs some regression test considering all the "resize" bugs in the current code

@rhatdan
Copy link
Member

rhatdan commented Mar 22, 2021

Let's fix this, getting the CI System to work with a TTY would be difficult,

@afbjorklund
Copy link
Contributor

afbjorklund commented Mar 22, 2021

I made a PR, but got some other fresh new error when trying it...

ERRO[0000] error unmounting /home/anders/.local/share/containers/storage/overlay/4f113f3daa4a1ec07ddb1e7f9428d21156eb9332186575a56a10314965d4303f/merged: invalid argument

Something about userxattr, whatever that is.

from containers/storage 1.28.0 containers/storage@6cb8896

Looks like it was added as a feature in Linux 5.9 ?

Workaround:

~/.config/containers/storage.conf

[storage]
  driver = "overlay"
  [storage.options]
    mount_program = "/usr/bin/fuse-overlayfs"

UPDATE: Reported as #9783


Seems to work OK.

@rhatdan
Copy link
Member

rhatdan commented Mar 23, 2021

@giuseppe ^^

@rhatdan
Copy link
Member

rhatdan commented Mar 23, 2021

@edsantiago came up with this test for the tty size.

        @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"
        }
         

@rhatdan
Copy link
Member

rhatdan commented Mar 23, 2021

@Luap99 could you create the PR and use the above test?

@edsantiago
Copy link
Member

@rhatdan @Luap99 I think this is being handled in #9782

@afbjorklund
Copy link
Contributor

Code change was the easy part, running and testing is harder...

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants