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

Output of podman ps --format=json #6980

Closed
buvoli opened this issue Jul 15, 2020 · 9 comments · Fixed by #7261
Closed

Output of podman ps --format=json #6980

buvoli opened this issue Jul 15, 2020 · 9 comments · Fixed by #7261
Assignees
Labels
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

@buvoli
Copy link

buvoli commented Jul 15, 2020

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

/kind bug

Description

The output of podman ps --format=json is missing fields compared to podman 1.9, and time fields are inconsistent. These changes cause problems for scripts that parse the ps command output.

Mislabeled Fields:

  • CreatedAt contains string instead of number

Missing fields:

  • Status (show in both docker and previous versions of podman)

Inconsistant Fields:

  • ID is now Id (both docker and previous versions of podman had ID)
  • command is now String[] instead of String

Steps to reproduce the issue:

  1. podman ps --format=json

Describe the results you received:

$ podman ps --format=json
[
  {
    "Command": [
      "bash"
    ],
    "Created": 1594776657,
    "CreatedAt": "2 hours ago",
    "Exited": false,
    "ExitedAt": -62135596800,
    "ExitCode": 0,
    "Id": "19dcc8d7b60eb6e629e0fb8c335ab9ff7aef81ee1a2ae7105d92f5a2cf6fb4b5",
    "Image": "localhost/fedora:latest",
    "ImageID": "ed63f8d268e45ea766d2886fa7b7c5cadc395372843446778f8e45b5f00cb799",
    "IsInfra": false,
    "Labels": {
      "license": "MIT",
      "name": "fedora",
      "vendor": "Fedora Project",
      "version": "32"
    },
    "Mounts": [ ],
    "Names": [
      "dazzling_shockley"
    ],
    "Namespaces": {
      
    },
    "Pid": 0,
    "Pod": "",
    "PodName": "",
    "Ports": null,
    "Size": null,
    "StartedAt": 1594776658,
    "State": "running"
  }
]

Describe the results you expected:

Only showing output for the aforementioned fields

$ podman ps --format=json
[
  {
    "ID": "19dcc8d7b60eb6e629e0fb8c335ab9ff7aef81ee1a2ae7105d92f5a2cf6fb4b5",
    "Command": "bash",
    "CreatedAt": 1594776657,
    "Status": "Up 2 hours"
  }
]

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

Output of podman version:

Version:      2.0.2
API Version:  1
Go Version:   go1.14.3
Built:        Thu Jan  1 00:00:00 1970
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.15.0
  cgroupVersion: v2
  conmon:
    package: conmon-2.0.18-1.fc32.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.18, commit: 6e8799f576f11f902cd8a8d8b45b2b2caf636a85'
  cpus: 2
  distribution:
    distribution: fedora
    version: "32"
  eventLogger: file
  hostname: ip-172-31-83-205.ec2.internal
  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: 5.6.6-300.fc32.x86_64
  linkmode: dynamic
  memFree: 1014763520
  memTotal: 2042073088
  ociRuntime:
    name: crun
    package: crun-0.14.1-1.fc32.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.14.1
      commit: 598ea5e192ca12d4f6378217d3ab1415efeddefa
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    path: /run/user/1000/podman/podman.sock
  rootless: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.1-1.fc32.x86_64
    version: |-
      slirp4netns version 1.1.1
      commit: bbf27c5acd4356edb97fa639b4e15e0cd56a39d5
      libslirp: 4.2.0
      SLIRP_CONFIG_VERSION_MAX: 2
  swapFree: 0
  swapTotal: 0
  uptime: 2h 20m 40.47s (Approximately 0.08 days)
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - registry.centos.org
  - docker.io
store:
  configFile: /home/fedora/.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.1.2-1.fc32.x86_64
      Version: |-
        fusermount3 version: 3.9.1
        fuse-overlayfs: version 1.1.0
        FUSE library version 3.9.1
        using FUSE kernel interface version 7.31
  graphRoot: /home/fedora/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 3
  runRoot: /run/user/1000/containers
  volumePath: /home/fedora/.local/share/containers/storage/volumes
version:
  APIVersion: 1
  Built: 0
  BuiltTime: Thu Jan  1 00:00:00 1970
  GitCommit: ""
  GoVersion: go1.14.3
  OsArch: linux/amd64
  Version: 2.0.2

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

podman-2.0.2-1.fc32.x86_64

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

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 15, 2020
@baude
Copy link
Member

baude commented Jul 15, 2020

@buvoli thanks for the report. We did change some fields with intent between 1.x and 2.x. The CreatedAt and Id fields were changed on purpose. @mheon and @jwhonce do either of you recall if the change in command type and the lack of Status was with intent?

@mheon
Copy link
Member

mheon commented Jul 15, 2020

Command is strange. It doesn't match what Docker is doing, and it doesn't match what we did before. Looks like a bug to me?

@mheon
Copy link
Member

mheon commented Jul 15, 2020

I also don't think there's a reason for Status to be not be included. It could be calculated from what we provide, and we're probably doing that in the frontend for ps right now, but if it's in v1 and Docker I don't see any reason it can't be in the JSON here.

@baude baude self-assigned this Jul 15, 2020
@baude
Copy link
Member

baude commented Jul 15, 2020

ok, those latter two, if we have consensus, I'll make a PR to fix.

@vasinov
Copy link

vasinov commented Jul 15, 2020

@baude Does CreatedAt's value being 2 hours ago make sense? It seems like it should be consistent with other timestamp fields like StartedAt and ExitedAt that use unix timestamps. Further, it doesn't read like proper English. I.e., "this was created at 2 hours ago."

@mheon
Copy link
Member

mheon commented Jul 15, 2020

Created is the timestamp form; CreatedAt is a human-readable form printed as part of podman ps and included in the JSON for use by some tools (most notably Toolbox)

@buvoli
Copy link
Author

buvoli commented Jul 15, 2020

@baude @mheon Thanks for the replies. I think it would be great to have Status added back, and for command to be a string again so that both fields match with docker and earlier versions of podman.

@baude you mentioned that changing ID to Id was an intentional decision. Is there a specific reason for this or is it still possible to keep things consistent with the output from docker ps --format='{{json .}}'? If not then it's not a huge deal since scripts can be easily rewritten to support both Id and ID.

@baude
Copy link
Member

baude commented Jul 16, 2020

@buvoli motivation was a little about the latter but primarily we were not consistent amongst podman itself. So that was probably the driving factor.

@buvoli
Copy link
Author

buvoli commented Aug 8, 2020

@baude I just tried podman 2.0.4 and noticed that the status command is still not present when running podman ps --format=json. Do you know if the status field will be eventually added back or will it be remove permanently now?

@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
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.

5 participants