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

crictl inspecti does not print valid JSON when multiple image IDs provided #669

Closed
honnix opened this issue Oct 7, 2020 · 7 comments · Fixed by #1493
Closed

crictl inspecti does not print valid JSON when multiple image IDs provided #669

honnix opened this issue Oct 7, 2020 · 7 comments · Fixed by #1493
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/node Categorizes an issue or PR as relevant to SIG Node.

Comments

@honnix
Copy link

honnix commented Oct 7, 2020

What happened:

I ran crictl inspecti -o json <id1> <id2>, and this output two JSON chunks instead of valid JSON array. The result makes using other tools to process output very hard.

What you expected to happen:

A valid JSON array containing two dictionaries.

How to reproduce it (as minimally and precisely as possible):

Run crictl inspecti -o json <id1> <id2> and examine the output.

Anything else we need to know?:

I guess the reason is that printing is done per image https://github.com/kubernetes-sigs/cri-tools/blob/master/cmd/crictl/image.go#L267, instead of composing a full JSON.

The same goes to YAML output as well.

So I think we can either output a complete JSON or have an option to output a single line json without pretty print. As for YAML, the only optional I think is to output multiple YAML doc separated by ---

Environment:

@honnix honnix added kind/bug Categorizes issue or PR as related to a bug. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Oct 7, 2020
@honnix
Copy link
Author

honnix commented Oct 7, 2020

A possible workaround could be replacing the output using regex \}\s*\{ with },{ and then padding []. Still feels flaky though.

@saschagrunert
Copy link
Member

Yeah, the same issue exists for inspecti and inspectp. The for loops are not taking the output type into account.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 6, 2021
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 5, 2021
@honnix
Copy link
Author

honnix commented Feb 10, 2021

I feel this will hardly be prioritized. /close

@honnix honnix closed this as completed Feb 10, 2021
@xiongtx
Copy link

xiongtx commented Jul 9, 2024

I'm running into this issue as well. When querying 100's of images on a host it's more efficient to do one shell command than 100's. Hopefully we can get an option to turn pretty-print off.

@saschagrunert saschagrunert reopened this Jul 10, 2024
@saschagrunert saschagrunert removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 10, 2024
@saschagrunert
Copy link
Member

Approaching a fix in #1493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/node Categorizes an issue or PR as relevant to SIG Node.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants