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

[APIv2] list containers: parameter limit doesn't work for non-running containers #6413

Closed
Edward5hen opened this issue May 28, 2020 · 5 comments · Fixed by #6710
Closed

[APIv2] list containers: parameter limit doesn't work for non-running containers #6413

Edward5hen opened this issue May 28, 2020 · 5 comments · Fixed by #6710
Assignees
Labels
HTTP API Bug is in RESTful API 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

@Edward5hen
Copy link
Contributor

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

/kind bug

Description
The DOC says query parameter limit

Return this number of most recently created containers, including non-running ones.

but it does not include non-running ones in my testing.

Steps to reproduce the issue:

  1.  podman system service --time 0 tcp:127.0.0.1:8081 &> ~/server.log &
    
[root@localhost ~]# podman ps -a
CONTAINER ID  IMAGE                                                                                    COMMAND          CREATED            STATUS                        PORTS   NAMES
177a5acdc613  docker.io/library/alpine:latest                                                          sleep 100        2 hours ago        Exited (0) 2 hours ago                testctn1
63265da07da7  docker.io/library/alpine:latest                                                          /bin/sh          About an hour ago  Exited (0) About an hour ago          jolly_austin
85c424218dd6  k8s.gcr.io/pause:3.2                                                                                      About an hour ago  Up About an hour ago                  0df430f23e2f-infra
a3d39d7e7066  localhost/osbs/rsyslog:extras-rhel-7.8-containers-candidate-63044-20200511205526-x86_64  /bin/rsyslog.sh  2 hours ago        Up 2 hours ago                        rsyslog
a9324a2b2c9f  docker.io/library/alpine:latest                                                          echo hello       2 hours ago        Exited (0) 2 hours ago                testctn2
f32cc00cd445  docker.io/library/alpine:latest                                                          echo hello       2 hours ago        Exited (0) 2 hours ago                testctn3
fc44f47c82fe  docker.io/library/alpine:latest                                                          sleep 1000       2 hours ago        Exited (0) 2 hours ago                testctn
  1. curl -v "http://localhost:8081/v1.40/libpod/containers/json?limit=5" | jq
    

Describe the results you received:
Only return the running ones.

[root@localhost ~]# curl -v "http://localhost:8081/v1.40/libpod/containers/json?limit=5" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ::1:8081...
* connect to ::1 port 8081 failed: Connection refused
*   Trying 127.0.0.1:8081...
* Connected to localhost (127.0.0.1) port 8081 (#0)
> GET /v1.40/libpod/containers/json?limit=5 HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.69.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 26 May 2020 17:45:05 GMT
< Transfer-Encoding: chunked
<
{ [3276 bytes data]
100  3264    0  3264    0     0  90666      0 --:--:-- --:--:-- --:--:-- 90666
* Connection #0 to host localhost left intact
[
  {
    "Command": null,
    "Created": 1590509182,
    "Exited": false,
    "ExitedAt": -62135596800,
    "ExitCode": 0,
    "Id": "85c424218dd6a29e2eba6c4171e88b7aedf96d214e513e784da0a0770271b2b3",
    "Image": "k8s.gcr.io/pause:3.2",
    "ImageID": "80d28bedfe5dec59da9ebf8e6260224ac9008ab5c11dbbe16ee3ba3e4439ac2c",
    "IsInfra": true,
    "Labels": null,
    "Mounts": [],
    "Names": [
      "0df430f23e2f-infra"
    ],
    "Namespaces": {},
    "Pid": 0,
    "Pod": "0df430f23e2fcd4aee64460f57a02508b26d4466ca701637852a45a3d9a2514d",
    "PodName": "",
    "Ports": null,
    "Size": null,
    "StartedAt": 1590509782,
    "State": "running"
  },
  {
    "Command": [
      "/bin/rsyslog.sh"
    ],
    "Created": 1590508558,
    "Exited": false,
    "ExitedAt": -62135596800,
    "ExitCode": 0,
    "Id": "a3d39d7e7066f054cbda291f8c8accfc3a85d8b92af6a1ef280a6c11d76cf2b4",
    "Image": "localhost/osbs/rsyslog:extras-rhel-7.8-containers-candidate-63044-20200511205526-x86_64",
    "ImageID": "ae4c2e58be6ffddc8044cfb2703093b86d6b1678989fc1942545a4bf6c25fa94",
    "IsInfra": false,
    "Labels": {
      "License": "GPLv3",
      "architecture": "x86_64",
      "build-date": "2020-05-11T20:55:32.252780",
      "com.redhat.build-host": "cpt-1005.osbs.prod.upshift.rdu2.redhat.com",
      "com.redhat.component": "rsyslog-container",
      "com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements",
      "description": "Rsyslogd is a system utility providing support for message logging. Support of both internet and unix domain sockets enables this utility to support both local and remote logging.",
      "distribution-scope": "public",
      "install": "docker run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=IMAGE -e NAME=NAME IMAGE /bin/install.sh",
      "io.k8s.description": "Rsyslogd is a system utility providing support for message logging. Support of both internet and unix domain sockets enables this utility to support both local and remote logging.",
      "io.k8s.display-name": "Rsyslog",
      "io.openshift.expose-services": "",
      "io.openshift.tags": "base rhel7",
      "maintainer": "Red Hat, Inc.",
      "name": "rhel7/rsyslog",
      "release": "12",
      "run": "docker run -d --privileged --name NAME --net=host --pid=host -v /etc/pki/rsyslog:/etc/pki/rsyslog -v /etc/rsyslog.conf:/etc/rsyslog.conf -v /etc/sysconfig/rsyslog:/etc/sysconfig/rsyslog -v /etc/rsyslog.d:/etc/rsyslog.d -v /var/log:/var/log -v /var/lib/rsyslog:/var/lib/rsyslog -v /run:/run -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -e IMAGE=IMAGE -e NAME=NAME --restart=always IMAGE /bin/rsyslog.sh",
      "summary": "A containerized version of the rsyslog utility for Red Hat Enterprise Linux 7.  The rsyslog container runs on a Red Hat Enterprise Linux 7 Atomic host to collect logs from various services.  The rsyslog container leverages the atomic command for installation, activation and management.",
      "uninstall": "docker run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=IMAGE -e NAME=NAME IMAGE /bin/uninstall.sh",
      "url": "https://access.redhat.com/containers/#/registry.access.redhat.com/rhel7/rsyslog/images/7.8-12",
      "vcs-ref": "3ae7d0b0ca3cf39fc7942f62d4c4be72860e46e9",
      "vcs-type": "git",
      "vendor": "Red Hat, Inc.",
      "version": "7.8"
    },
    "Mounts": [
      "/etc/rsyslog.d",
      "/var/lib/rsyslog",
      "/run",
      "/etc/pki/rsyslog",
      "/etc/sysconfig/rsyslog",
      "/var/log",
      "/etc/machine-id",
      "/etc/localtime",
      "/etc/rsyslog.conf"
    ],
    "Names": [
      "rsyslog"
    ],
    "Namespaces": {},
    "Pid": 0,
    "Pod": "",
    "PodName": "",
    "Ports": null,
    "Size": null,
    "StartedAt": 1590508558,
    "State": "running"
  }
]

Describe the results you expected:
List 5 containers including the non-running ones.

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

[root@localhost ~]# podman version
Version:      2.0.0-dev
API Version:  1
Go Version:   go1.14.2
Git Commit:   1077d2d0b72d027a01080c0d3ebdb7d99a969661
Built:        Tue May 26 14:51:01 2020
OS/Arch:      linux/amd64

Output of podman info --debug:

[root@localhost ~]# podman info --debug
host:
  arch: amd64
  buildahVersion: 1.15.0-dev
  cgroupVersion: v2
  conmon:
    package: conmon-2.0.15-1.fc32.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.15, commit: 33da5ef83bf2abc7965fc37980a49d02fdb71826'
  cpus: 2
  distribution:
    distribution: fedora
    version: "32"
  eventLogger: file
  hostname: localhost.localdomain
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.6.6-300.fc32.x86_64
  linkmode: dynamic
  memFree: 275668992
  memTotal: 2068803584
  ociRuntime:
    name: crun
    package: crun-0.13-2.fc32.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.13
      commit: e79e4de4ac16da0ce48777afb72c6241de870525
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  rootless: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 2204626944
  swapTotal: 2206199808
  uptime: 34h 16m 17.56s (Approximately 1.42 days)
registries:
  localhost:
    Blocked: false
    Insecure: true
    Location: localhost
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: localhost
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - registry.centos.org
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 7
    paused: 0
    running: 2
    stopped: 5
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "true"
  imageStore:
    number: 4
  runRoot: /var/run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 1
  Built: 1590475861
  BuiltTime: Tue May 26 14:51:01 2020
  GitCommit: 1077d2d0b72d027a01080c0d3ebdb7d99a969661
  GoVersion: go1.14.2
  OsArch: linux/amd64
  Version: 2.0.0-dev

Additional environment details (AWS, VirtualBox, physical, etc.):
fedora32 guest

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 28, 2020
@vrothberg vrothberg self-assigned this May 28, 2020
@vrothberg
Copy link
Member

Thanks a lot for the issue! I'll take a look at it now.

@vrothberg
Copy link
Member

Ah, the implementation uses a last parameter for this.

@baude, @jwhonce, what's the "right" name for the parameter? "limit" or "last"?

@vrothberg
Copy link
Member

Ironically, --last doesn't list as described either as it only lists running ones (also on CLI).

@vrothberg
Copy link
Member

Opened #6416 to fix the --last bug. The naming issue regarding swagger is not addressed.

@mheon mheon added the HTTP API Bug is in RESTful API label Jun 2, 2020
@vrothberg
Copy link
Member

@baude @jwhonce ping.

@baude, @jwhonce, what's the "right" name for the parameter? "limit" or "last"?

vrothberg added a commit to vrothberg/libpod that referenced this issue Jun 22, 2020
Support both `last` and `limit` for in the containers listing endpoint.
We intended to use `limit` which is also mentioned in the docs, but the
implementation ended up using `last` as the http parameter; likely being
caused by the CLI using `--last`.  To avoid any regression, we decided
for supporting both and aliasing `last`.

Fixes: containers#6413
Signed-off-by: Valentin Rothberg <[email protected]>
@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 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
HTTP API Bug is in RESTful API 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.

4 participants