Bug 1289456
Summary: | "--sort-by" option does not take effect for oc get, oc run etc | |||
---|---|---|---|---|
Product: | OKD | Reporter: | Xingxing Xia <xxia> | |
Component: | Pod | Assignee: | Avesh Agarwal <avagarwa> | |
Status: | CLOSED CURRENTRELEASE | QA Contact: | Jianwei Hou <jhou> | |
Severity: | low | Docs Contact: | ||
Priority: | medium | |||
Version: | 3.x | CC: | aos-bugs, avagarwa, mmccomas | |
Target Milestone: | --- | |||
Target Release: | --- | |||
Hardware: | Unspecified | |||
OS: | Unspecified | |||
Whiteboard: | ||||
Fixed In Version: | Doc Type: | Bug Fix | ||
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1332828 (view as bug list) | Environment: | ||
Last Closed: | 2016-09-19 13:49:46 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 1332828 |
Description
Xingxing Xia
2015-12-08 07:50:49 UTC
I have tested this on latest kubernetes and origin code bases today, it seems that creationTimestamp and "$%#@&&" are not a valid thing for sort-by, and it is consistent with both kube and origin. The link https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/kubectl-overview.md gives guidelines for how to use it sort-by. By now, I do not see any issue with sort-by. Honestly I have not tried all sort of options with sort-by, but if you have something specific, please let me know, I will try them. Note: there is a typo in the description: medadata->metadata To reproduce on origin (master and node on VM): 1. openshift start master --write-config=./openshift.local.config/master 2. oadm create-node-config --node-dir=./openshift.local.config/node-192.168.122.253 --node=192.168.122.253 --hostnames=192.168.122.253 3. openshift start master --config=./openshift.local.config/master/master-config.yaml 4. (In another terminal) openshift start node --config=./openshift.local.config/node-192.168.122.253/node-config.yaml 5. (In another terminal) [root@localhost origin]# oc get pods --sort-by=.metadata.creationTimestamp --config=./openshift.local.config/master/admin.kubeconfig F0127 14:29:14.925363 8841 sorting_printer.go:182] Field {.metadata.creationTimestamp} in &{{ } {bwide-pause-rc-tu940 bwide-pause-rc- default /api/v1/namespaces/default/pods/bwide-pause-rc-tu940 7cb06865-c52b-11e5-88d4-5254005eb708 243 0 2016-01-27 14:23:47 -0500 EST <nil> <nil> map[name:bwide-pause-ls] map[kubernetes.io/created-by:{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicationController","namespace":"default","name":"bwide-pause-rc","uid":"7cafa9d5-c52b-11e5-88d4-5254005eb708","apiVersion":"v1","resourceVersion":"232"}} openshift.io/scc:restricted]} {[{default-token-sz7xs {<nil> <nil> <nil> <nil> <nil> 0xc820316f80 <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil>}}] [{bwide-pause-c gcr.io/google_containers/pause:2.0 [] [] [] [] {map[] map[]} [{default-token-sz7xs true /var/run/secrets/kubernetes.io/serviceaccount}] <nil> <nil> <nil> /dev/termination-log IfNotPresent 0xc82023d530 false false false}] Always 0xc820317470 <nil> ClusterFirst map[] default 192.168.122.253 0xc8200b6b80 [{default-dockercfg-gtsr8}]} {Running [{Ready True 0001-01-01 00:00:00 +0000 UTC 2016-01-27 14:23:52 -0500 EST }] 192.168.122.253 172.17.0.2 2016-01-27 14:23:47 -0500 EST [{bwide-pause-c {<nil> 0xc820264960 <nil>} {<nil> <nil> <nil>} true 0 gcr.io/google_containers/pause:2.0 docker://9981ca1bbdb5f334706905879dbd73d0146fc9327fa30d4f2021cec660dd19fc docker://39a449c69b8bcb0f88d8acbb48ffef5319c1adc4f8e9946461701bc257a8cc46}]}} is an unsortable type: struct, err: unsortable type: struct [root@localhost origin]# oc get pods --sort-by="$%#@&&" --config=./openshift.local.config/master/admin.kubeconfig error: unrecognized character in action: U+0025 '%' Please note that creationTimestamp is infact a valid metadata, but when I say it may not be valid for sort-by just because its behaviour is consistent with kube and origin. It could be argued that it should work same way as .metadata.name for example, but i am not sure if that is intended. For example oc get events --sort-by works for --sort-by=count but not for --sort-by=firstseen or lastseen. So may be sort-by is not intended (or implemented) to work with all fields or metadata types it seems to me. (In reply to Avesh Agarwal from comment #2) > Please note that creationTimestamp is infact a valid metadata, but when I > say it may not be valid for sort-by just because its behaviour is consistent > with kube and origin. It could be argued that it should work same way as > .metadata.name for example, but i am not sure if that is intended. For > example oc get events --sort-by works for --sort-by=count but not for > --sort-by=firstseen or lastseen. So may be sort-by is not intended (or > implemented) to work with all fields or metadata types it seems to me. 1. At the time this bug was reported, using --sort-by="{medadata.creationTimestamp}" and --sort-by="$%#@&&", `oc get pod` did ran without error message and did not recognize them as invalid. Right now they are invalid, it may be due to the code is updated in the latest Origin version. 2. `oc get -h` shows the sort field must be an integer or a string. But it seems --sort-by only applies to OpenShift resource fields that are from kube. it cannot sort by OpenShift resource fields that are not from kube. e.g., pod/rc use Kube API, dc/bc use OpenShift API. The two get different results: $ oc new-app -f origin/examples/sample-app/application-template-stibuild.json $ oc scale dc database --replicas=3 $ oc get pod --sort-by=".metadata.name" # Works NAME READY STATUS RESTARTS AGE database-1-5f7yc 1/1 Running 0 29m database-1-6uuv2 1/1 Running 0 46m database-1-8qd84 1/1 Running 0 29m frontend-1-8yi99 1/1 Running 0 45m frontend-1-zit1v 1/1 Running 0 45m $ oc get rc --sort-by=".spec.replicas" # Works But: $ oc get dc --sort-by=".metadata.name" # Not work error: metadata is not found $ oc get bc --sort-by=".metadata.name" # Not work error: metadata is not found 3. --sort-by disturbs column indentation of the output: $ oc run pod --image=docker.io/openshift/hello-openshift --generator=run-pod/v1 $ oc run pod-longname --image=docker.io/openshift/hello-openshift --generator=run-pod/v1 $ oc get pod # Spaces indent well NAME READY STATUS RESTARTS AGE pod 1/1 Running 0 18s pod-longname 1/1 Running 0 8s $ oc get pod --sort-by=".metadata.name" # Spaces not indent well pod 1/1 Running 0 32s pod-longname 1/1 Running 0 22s Points 2 and 3 are problems. I am aware of the 3rd problem, and will reproduce the 2nd one today. Thanks. Sent following PR to fix sort-by indentation issue: https://github.com/kubernetes/kubernetes/pull/20803 sent following PR to address metadata error issue: https://github.com/kubernetes/kubernetes/pull/21694 The changes (https://github.com/kubernetes/kubernetes/pull/21694) are in origin master now. Verified with openshift v1.3.0-alpha.0-586-gcd9ea84 $ oc get dc --sort-by="{.metadata.resourceVersion}" NAME REVISION REPLICAS TRIGGERED BY database 1 1 config helloapp 1 1 config,image(helloapp:latest) frontend 1 2 config,image(origin-ruby-sample:latest) $ oc get dc database helloapp frontend -o yaml | grep 'resourceVersion: ' resourceVersion: "502" resourceVersion: "580" resourceVersion: "634" Points 2 and 3 in comment 3 are fixed. Thank you! |