Bug 1579515 - Unexpected error when sort-by and -o yaml provided
Summary: Unexpected error when sort-by and -o yaml provided
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.10.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 3.10.0
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-17 20:14 UTC by Clayton Coleman
Modified: 2019-04-09 23:40 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-04-09 23:40:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0620 0 None None None 2019-04-09 23:40:52 UTC

Description Clayton Coleman 2018-05-17 20:14:10 UTC
I got an error when running oc get events in 3.10 against a 3.10 server:

$ oc get events --all-namespaces --sort-by '{.metadata.creationTimestamp}' -o json
error: unexpected path string, expected a 'name1.name2' or '.name1.name2' or '{name1.name2}' or '{.name1.name2}'

Unexpected.

Comment 1 Juan Vallejo 2018-05-17 21:47:33 UTC
Moving severity to low, as the workaround for this is to not wrap the jsonpath in "{ }".

This is caused in origin because the "SortingPrinter" is instantiated with the user-specified key already wrapped in braces [1]. So the value `--sort-by {.metadata.name}` ends up being parsed as `{{.metadata.name}}`.

I have opened a PR upstream that restores expected behavior [2].

1. https://github.com/openshift/origin/blob/master/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/util/printing.go#L231

2. https://github.com/kubernetes/kubernetes/pull/64001

Comment 2 Juan Vallejo 2018-05-18 20:48:01 UTC
Origin PR: https://github.com/openshift/origin/pull/19777

Comment 4 Maciej Szulik 2019-02-27 21:51:10 UTC
Fix landed in 3.10, moving to qa.

Comment 5 zhou ying 2019-02-28 05:34:34 UTC
The issue has fixed with ocp 3.10:
[root@qe-yinzhou-310-master-etcd-1 ~]# oc version
oc v3.10.118
kubernetes v1.10.0+b81c8f8
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://qe-yinzhou-310-master-etcd-1:8443
openshift v3.10.118
kubernetes v1.10.0+b81c8f8
[root@qe-yinzhou-310-master-etcd-1 ~]# oc get events --all-namespaces --sort-by '{.metadata.creationTimestamp}'  -o json
{
    "apiVersion": "v1",
    "items": [
        {
            "apiVersion": "v1",
            "count": 1,
            "eventTime": null,
            "firstTimestamp": "2019-02-28T03:39:10Z",
            "involvedObject": {
                "apiVersion": "v1",
                "fieldPath": "spec.containers{sync}",
                "kind": "Pod",
                "name": "sync-k2pbr",
                "namespace": "openshift-node",
                "resourceVersion": "1501",
                "uid": "687f168f-3b0a-11e9-9d88-fa163e5976d9"
            },
            "kind": "Event",
......

Comment 7 errata-xmlrpc 2019-04-09 23:40:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:0620


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