Bug 1900755 - Wrong output when using jsonpath with "oc get".
Summary: Wrong output when using jsonpath with "oc get".
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.6.z
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Robin Cernin
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-23 16:33 UTC by Sergio G.
Modified: 2024-12-20 19:24 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-08-09 13:19:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubernetes kubernetes pull 98057 0 None closed [jsonpath] fix wrong output when using jsonpath 2021-06-03 00:47:30 UTC

Description Sergio G. 2020-11-23 16:33:04 UTC
Description of problem:
When parsing a list with jsonpath a extra empty item is included.


Version-Release number of selected component (if applicable):
4.6.4


How reproducible:
Always


Steps to Reproduce:
$ openshift-client-linux-4.6.4 get -n openshift-oauth-apiserver po -o jsonpath='{range .items[?(.status.phase=="Running")]}{.metadata.name}{" is Running\n"}'
apiserver-655f678dd-6s2lt is Running
apiserver-655f678dd-7krvg is Running
apiserver-655f678dd-pzvph is Running
 is Running

Expected results:
No last line with empty .metadata.name


Additional info:
This doesn't happen with 4.5 client:
$ openshift-client-linux-4.5.19 get -n openshift-oauth-apiserver po -o jsonpath='{range .items[?(.status.phase=="Running")]}{.metadata.name}{" is Running\n"}'
apiserver-655f678dd-6s2lt is Running
apiserver-655f678dd-7krvg is Running
apiserver-655f678dd-pzvph is Running


Confirmed every single 4.6.z version of oc and kubectl packed in the download tgz from mirror.openshift.com.


For more information, I've noticed that there's one dependency related with json that has been upgraded in the change from oc-4.5-kubernetes-1.18.8 to oc-4.6-kubernetes-1.19 in openshift/kubernetes-kubectl. The dependency is github.com/json-iterator/go which has been upgraded from rev v1.1.18 to v1.1.10. Not sure if the issue comes from there, but I haven't found any other hint in our code.

Comment 1 Maciej Szulik 2020-12-04 16:30:21 UTC
I’m adding UpcomingSprint, because I was occupied by fixing bugs with higher priority/severity, developing new features with higher priority, or developing new features to improve stability at a macro level. I will revisit this bug next sprint.

Comment 4 Maciej Szulik 2021-01-14 11:31:13 UTC
A(In reply to Robin Cernin from comment #2)
> I proposed a PR upstream https://github.com/kubernetes/kubernetes/pull/98057

Awesome, I'll have a look at it sometime soon-ish :-) Thanks!

Comment 13 Maciej Szulik 2021-04-29 12:21:39 UTC
I'm hoping to get to this sometime next week.

Comment 14 Robin Cernin 2021-06-03 00:48:08 UTC
Merged upstream in https://github.com/kubernetes/kubernetes/pull/98057

Comment 15 Maciej Szulik 2021-06-08 11:18:53 UTC
We should get it along with k8s 1.22 bump, in that case.

Comment 16 Filip Krepinsky 2021-08-05 16:54:28 UTC
the original problem doesn't seem like a bug because it is using incorrect jsonpath syntax. It is missing the {end} element. Please see https://kubernetes.io/docs/reference/kubectl/jsonpath/.

The fix for this however caused a bug in one of our tests: https://bugzilla.redhat.com/show_bug.cgi?id=1989505.

I have posted a PR for reverting the original fix: https://github.com/kubernetes/kubernetes/pull/104172

I propose closing this bug as not a bug.

Comment 17 Maciej Szulik 2021-08-09 13:19:56 UTC
Based on previous comment I'm closing this as not a bug. The original problem was that the jsonpath statement was missing {end}.


Note You need to log in before you can comment on or make changes to this bug.