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

improve tkctl get command output #822

Merged
merged 8 commits into from
Aug 27, 2019

Conversation

onlymellb
Copy link
Contributor

@onlymellb onlymellb commented Aug 23, 2019

What problem does this PR solve?

fix #821 and support for viewing details of a specific pod or PV

What is changed and how does it work?

Check List

Tests

  • Manual test
  1. Unify the output format of multiple clusters, remove the NAMESPACE column of PV. Change CLAIM colume of PV from <pvc_name> to <namespace>/<pvc_name>
$ tkctl get pd,tidb,volume -A
Cluster: test1/demo1
NAMESPACE   NAME         READY   STATUS    MEMORY          CPU             RESTARTS   AGE
test1       demo1-pd-0   1/1     Running   <none>/<none>   <none>/<none>   0          14d
test1       demo1-pd-1   1/1     Running   <none>/<none>   <none>/<none>   0          14d
test1       demo1-pd-2   1/1     Running   <none>/<none>   <none>/<none>   0          14d
NAMESPACE   NAME           READY   STATUS    MEMORY     CPU        RESTARTS   AGE
test1       demo1-tidb-0   2/2     Running   5Mi/50Mi   20m/100m   0          14d
test1       demo1-tidb-1   2/2     Running   5Mi/50Mi   20m/100m   0          14d
VOLUME                                     CLAIM                     STATUS   CAPACITY   STORAGECLASS
pvc-a90d84c1-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-0       Bound    1Gi        rook-ceph-block
pvc-a90f9c1b-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-1       Bound    1Gi        rook-ceph-block
pvc-a911506a-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-2       Bound    1Gi        rook-ceph-block
pvc-d4031d35-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-0   Bound    10Gi       rook-ceph-block
pvc-d404a72e-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-1   Bound    10Gi       rook-ceph-block
pvc-d4065414-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-2   Bound    10Gi       rook-ceph-block

Cluster: test2/demo2
NAMESPACE   NAME         READY   STATUS    MEMORY          CPU             RESTARTS   AGE
test2       demo2-pd-0   1/1     Running   <none>/<none>   <none>/<none>   0          11d
test2       demo2-pd-1   1/1     Running   <none>/<none>   <none>/<none>   1          11d
test2       demo2-pd-2   1/1     Running   <none>/<none>   <none>/<none>   0          11d
NAMESPACE   NAME           READY   STATUS    MEMORY     CPU        RESTARTS   AGE
test2       demo2-tidb-0   2/2     Running   5Mi/50Mi   20m/100m   0          11d
test2       demo2-tidb-1   2/2     Running   5Mi/50Mi   20m/100m   0          11d
VOLUME                                     CLAIM                     STATUS   CAPACITY   STORAGECLASS
pvc-3c8b98cc-bcef-11e9-9002-525400d6f2a6   test2/pd-demo2-pd-0       Bound    1Gi        rook-ceph-block
pvc-3c8cda85-bcef-11e9-9002-525400d6f2a6   test2/pd-demo2-pd-1       Bound    1Gi        rook-ceph-block
pvc-3c8e10d0-bcef-11e9-9002-525400d6f2a6   test2/pd-demo2-pd-2       Bound    1Gi        rook-ceph-block
pvc-5669b2b9-bcef-11e9-9002-525400d6f2a6   test2/tikv-demo2-tikv-0   Bound    10Gi       rook-ceph-block
pvc-566b0da6-bcef-11e9-9002-525400d6f2a6   test2/tikv-demo2-tikv-1   Bound    10Gi       rook-ceph-block
pvc-566ca86f-bcef-11e9-9002-525400d6f2a6   test2/tikv-demo2-tikv-2   Bound    10Gi       rook-ceph-block
  1. Support use -owide to see the omitted columns, add IP colume for pd/tikv/tidb, and STOAGECLASS colume for PV
$ tkctl get pd,volume
NAME         READY   STATUS    MEMORY          CPU             RESTARTS   AGE
demo1-pd-0   1/1     Running   <none>/<none>   <none>/<none>   0          14d
demo1-pd-1   1/1     Running   <none>/<none>   <none>/<none>   0          14d
demo1-pd-2   1/1     Running   <none>/<none>   <none>/<none>   0          14d
VOLUME                                     CLAIM                     STATUS   CAPACITY   STORAGECLASS
pvc-a90d84c1-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-0       Bound    1Gi        rook-ceph-block
pvc-a90f9c1b-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-1       Bound    1Gi        rook-ceph-block
pvc-a911506a-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-2       Bound    1Gi        rook-ceph-block
pvc-d4031d35-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-0   Bound    10Gi       rook-ceph-block
pvc-d404a72e-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-1   Bound    10Gi       rook-ceph-block
pvc-d4065414-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-2   Bound    10Gi       rook-ceph-block

$ tkctl get pd,volume -owide
NAME         READY   STATUS    MEMORY          CPU             RESTARTS   AGE   IP               NODE
demo1-pd-0   1/1     Running   <none>/<none>   <none>/<none>   0          14d   10.233.89.12     172.16.5.164
demo1-pd-1   1/1     Running   <none>/<none>   <none>/<none>   0          14d   10.233.69.70     172.16.5.165
demo1-pd-2   1/1     Running   <none>/<none>   <none>/<none>   0          14d   10.233.109.198   172.16.5.163
VOLUME                                     CLAIM                     STATUS   CAPACITY   STORAGECLASS      NODE     LOCAL
pvc-a90d84c1-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-0       Bound    1Gi        rook-ceph-block   <none>   <none>
pvc-a90f9c1b-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-1       Bound    1Gi        rook-ceph-block   <none>   <none>
pvc-a911506a-ba97-11e9-8a21-525400d6f2a6   test1/pd-demo1-pd-2       Bound    1Gi        rook-ceph-block   <none>   <none>
pvc-d4031d35-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-0   Bound    10Gi       rook-ceph-block   <none>   <none>
pvc-d404a72e-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-1   Bound    10Gi       rook-ceph-block   <none>   <none>
pvc-d4065414-ba97-11e9-8a21-525400d6f2a6   test1/tikv-demo1-tikv-2   Bound    10Gi       rook-ceph-block   <none>   <none>
  1. fix output nothing with -oyaml or -ojson option
$ tkctl get volume -oyaml
apiVersion: v1
items:
- apiVersion: v1
  kind: PersistentVolume
  metadata:
    annotations:
      pv.kubernetes.io/provisioned-by: ceph.rook.io/block
      tidb.pingcap.com/pod-name: demo1-tikv-2
    creationTimestamp: "2019-08-09T11:21:27Z"
...
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

$ tkctl get volume -ojson
{
    "apiVersion": "v1",
    "items": [
        {
            "apiVersion": "v1",
            "kind": "PersistentVolume",
            "metadata": {
                "annotations": {
                    "pv.kubernetes.io/provisioned-by": "ceph.rook.io/block",
                    "tidb.pingcap.com/pod-name": "demo1-tikv-2"
                },
                "creationTimestamp": "2019-08-09T11:21:27Z",
...
    "kind": "List",
    "metadata": {
        "resourceVersion": "",
        "selfLink": ""
    }
}
  1. Support for viewing details of a specific pod or PV
$ tkctl get pd demo1-pd-0 -oyaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
...
status:
...
  hostIP: 172.16.5.164
  phase: Running
  podIP: 10.233.89.12
  qosClass: BestEffort
  startTime: "2019-08-09T11:20:30Z"

$ tkctl get volume pvc-a90d84c1-ba97-11e9-8a21-525400d6f2a6 -ojson
{
    "kind": "PersistentVolume",
    "apiVersion": "v1",
    "metadata": {
        "name": "pvc-a90d84c1-ba97-11e9-8a21-525400d6f2a6",
        "selfLink": "/api/v1/persistentvolumes/pvc-a90d84c1-ba97-11e9-8a21-525400d6f2a6",
        "uid": "b1ccca8a-ba97-11e9-8a21-525400d6f2a6",
        "resourceVersion": "177259",
        "creationTimestamp": "2019-08-09T11:20:29Z",
...
    "status": {
        "phase": "Bound"
    }
}

Code changes

  • Has Go code change

Side effects

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Does this PR introduce a user-facing change?:

fix ouput nothing with -oyaml or -ojson option and support for viewing details of a specific pod or PV,  also improve get comand output

aylei
aylei previously approved these changes Aug 25, 2019
Copy link
Contributor

@aylei aylei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@onlymellb
Copy link
Contributor Author

/run-e2e-test

@onlymellb
Copy link
Contributor Author

/run-e2e-in-kind

@onlymellb
Copy link
Contributor Author

/run-e2e-in-kind

Copy link
Contributor

@shuijing198799 shuijing198799 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shuijing198799 shuijing198799 merged commit c62324d into pingcap:master Aug 27, 2019
@onlymellb onlymellb deleted the optimize-tkctl-get-output branch August 27, 2019 08:01
@sre-bot
Copy link
Contributor

sre-bot commented Aug 27, 2019

cherry pick to release-1.0 in PR #834

onlymellb pushed a commit that referenced this pull request Aug 27, 2019
* fix wrong binary name

* support output info with -owide

* improve get command output

* add more example
yahonda pushed a commit that referenced this pull request Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tkctl ouput does not meet expectations
5 participants