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

buildah images --json createatraw subsecond precision makes jq processing hard #3478

Closed
grooverdan opened this issue Aug 25, 2021 · 3 comments · Fixed by #3482
Closed

buildah images --json createatraw subsecond precision makes jq processing hard #3478

grooverdan opened this issue Aug 25, 2021 · 3 comments · Fixed by #3482

Comments

@grooverdan
Copy link

Description

Attempting to script operations based on buildah images --json with regard to .createatraw (added #1266) using jq as a shell based tool gets hard. The ability for jq to be extended to support subsecond precision is also hard due to glibc functions not supporting parsing of it.

Steps to reproduce the issue:

  1. take buildah images --json output in a script
  2. attempt to filter using jq based on Unix epoch using .createdatraw converted to fromdateiso8601
$ lastweek=$(date +%s --date='1 week ago')
$ buildah images --json |  jq ".[] |  select(.createdatraw  | fromdateiso8601 <= $lastweek)"
jq: error (at <stdin>:408): date "2021-07-26T21:21:31.071665434Z" does not match format "%Y-%m-%dT%H:%M:%SZ"

ref: jq manual - https://stedolan.github.io/jq/manual/s

Describe the results you received:

The subsecond precision isn't there in jq. jq uses strptime which also don't have a field for subsecond parsing.

Describe the results you expected:

The .createdateraw without the subscond would be easy to parse rather than the regex that I've used in MariaDB/mariadb.org-tools@626366b

Output of rpm -q buildah or apt list buildah:

$ rpm -q buildah
buildah-1.21.4-1.module+el8.4.0+11989+6676f7ad.x86_64

Output of buildah version:

Version:         1.21.4
Go Version:      go1.15.7
Image Spec:      1.0.1-dev
Runtime Spec:    1.0.2-dev
CNI Spec:        0.4.0
libcni Version:  v0.8.1
image Version:   5.12.0
Git Commit:      
Built:           Tue Jul 27 09:29:47 2021
OS/Arch:         linux/amd64

Output of cat /etc/*release:

NAME="Red Hat Enterprise Linux"
VERSION="8.4 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.4 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.4:GA"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/red_hat_enterprise_linux/8/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.4
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.4"
Red Hat Enterprise Linux release 8.4 (Ootpa)
Red Hat Enterprise Linux release 8.4 (Ootpa)

Output of uname -a:

Linux bb-rhel8-docker 4.18.0-305.3.1.el8_4.x86_64 #1 SMP Mon May 17 10:08:25 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of cat /etc/containers/storage.conf:

$ egrep -v '^(#|$)' < /etc/containers/storage.conf
[storage]
driver = "overlay"
runroot = "/run/containers/storage"
graphroot = "/var/lib/containers/storage"
[storage.options]
additionalimagestores = [
]
[storage.options.overlay]
mountopt = "nodev,metacopy=on"
[storage.options.thinpool]
@rhatdan
Copy link
Member

rhatdan commented Aug 25, 2021

$ podman images --format json
has
"Created": 1628008986,
"CreatedAt": "2021-08-03T16:43:06Z"

Would that work for you? IE Would adding Created: EPOCH Seconds work?

@grooverdan
Copy link
Author

EPOCH Seconds would be perfect.

rhatdan added a commit to rhatdan/buildah that referenced this issue Aug 26, 2021
Currently buildah images does not have an easy way to get the epoch
creation time. This field is available in `podman images` as the
Created field. Adding to buildah images to make it consistent.

Fixes: containers#3478

Signed-off-by: Daniel J Walsh <[email protected]>
rhatdan added a commit to rhatdan/buildah that referenced this issue Aug 26, 2021
Currently buildah images does not have an easy way to get the epoch
creation time. This field is available in `podman images` as the
Created field. Adding to buildah images to make it consistent.

Fixes: containers#3478

Signed-off-by: Daniel J Walsh <[email protected]>
@grooverdan
Copy link
Author

Thank you @rhatdan.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants