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

show concise image info for crictl ps #361

Merged
merged 2 commits into from Aug 13, 2018

Conversation

yanxuean
Copy link
Contributor

@yanxuean yanxuean commented Aug 3, 2018

fix #360

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 3, 2018
@yanxuean
Copy link
Contributor Author

yanxuean commented Aug 3, 2018

[root@cloud-test2:/home/cloud]$ ./crictl ps -o table
CONTAINER ID        IMAGE               CREATED             STATE               NAME                ATTEMPT
c2225d62949e5       9f76b554c615d       7 days ago          Running             virtlet             3
6d2fbbd64e247       9f76b554c615d       7 days ago          Running             vms                 0
0cbcda42d1dc9       9f76b554c615d       7 days ago          Running             libvirt             0
161b79ae8ae27       32609f1b11ae7       7 days ago          Running             kube-proxy          4
[root@cloud-test2:/home/cloud]$ ./crictl images
IMAGE                                                  TAG                 IMAGE ID            SIZE
busybox                                                latest              22c2dd5ee85dc       1.16MB
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64   1.14.5              459944ce8cc4f       41.4MB
gcr.io/google_containers/k8s-dns-kube-dns-amd64        1.14.5              512cd7425a731       49.4MB
gcr.io/google_containers/k8s-dns-sidecar-amd64         1.14.5              fed89e8b4248a       41.8MB
gcr.io/google_containers/kube-proxy-amd64              v1.10.5             32609f1b11ae7       97.9MB
gcr.io/google_containers/pause-amd64                   3.0                 99e59f495ffaa       747kB
k8s.gcr.io/pause-amd64                                 3.1                 da86e6ba6ca19       742kB
mirantis/virtlet                                       latest              9f76b554c615d       891MB

[root@cloud-test2:/home/cloud]$ ./crictl pods -o table
POD ID              CREATED             STATE               NAME                NAMESPACE           ATTEMPT
598b5d4718988       7 days ago          Ready               virtlet-d4zdj       kube-system         0
da906c88114ee       7 days ago          Ready               kube-proxy-bqnhm    kube-system         3
b1a254f3260b6       7 days ago          NotReady            kube-proxy-bqnhm    kube-system         2
[root@cloud-test2:/home/cloud]$

@Random-Liu Random-Liu self-assigned this Aug 3, 2018
@yanxuean yanxuean changed the title Concise imageid show concise image info for crictl ps Aug 4, 2018
id = id[:truncatedIDLen]
}
}
id := getTruncatedID(opts.noTrunc, c.Id, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be:

if !opts.noTrunc {
  id := getTruncatedID(c.Id, "")
}

It is weird that function getTruncatedID has a bool parameter to indicate returning a non-truncated id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
id := getTruncatedID(opts.noTrunc, c.Id, "")
// Now c.Image.Image is imageID in kubelet.
imageID := getTruncatedID(opts.noTrunc, c.Image.Image, "sha256:")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use go-digest to parse the id here? We should only truncate when it is an image id.

The kubelet implementation may change in the future, we should not rely on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 11, 2018
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 11, 2018
@yanxuean
Copy link
Contributor Author

yanxuean commented Aug 11, 2018

[root@cloud-test2:/home/cloud]$ docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS               NAMES
9f7a48803a2f        9f76b554c615                 "/vms.sh"                21 hours ago        Up 21 hours                             k8s_vms_virtlet-wcb8r_kube-system_487bc52a-9c77-11e8-b87c-52540031cdce_0
b940b37a9f9e        9f76b554c615                 "/start.sh"              21 hours ago        Up 21 hours                             k8s_virtlet_virtlet-wcb8r_kube-system_487bc52a-9c77-11e8-b87c-52540031cdce_0
7fb15432579f        9f76b554c615                 "/libvirt.sh"            21 hours ago        Up 21 hours                             k8s_libvirt_virtlet-wcb8r_kube-system_487bc52a-9c77-11e8-b87c-52540031cdce_0
3f075e72dfa2        k8s.gcr.io/pause-amd64:3.1   "/pause"                 21 hours ago        Up 21 hours                             k8s_POD_virtlet-wcb8r_kube-system_487bc52a-9c77-11e8-b87c-52540031cdce_0
f60944900ceb        32609f1b11ae                 "/usr/local/bin/kube-"   21 hours ago        Up 21 hours                             k8s_kube-proxy_kube-proxy-bqnhm_kube-system_fad6d780-90a5-11e8-b3cf-52540031cdce_6
ab863e4ae6f3        k8s.gcr.io/pause-amd64:3.1   "/pause"                 21 hours ago        Up 21 hours                             k8s_POD_kube-proxy-bqnhm_kube-system_fad6d780-90a5-11e8-b3cf-52540031cdce_0
[root@cloud-test2:/home/cloud]$
[root@cloud-test2:/home/cloud]$ ./crictl ps -o table
CONTAINER ID        IMAGE               CREATED             STATE               NAME                ATTEMPT
9f7a48803a2f5       9f76b554c615d       22 hours ago        Running             vms                 0
b940b37a9f9ee       9f76b554c615d       22 hours ago        Running             virtlet             0
7fb15432579fa       9f76b554c615d       22 hours ago        Running             libvirt             0
f60944900ceb3       32609f1b11ae7       22 hours ago        Running             kube-proxy          6
[root@cloud-test2:/home/cloud]$ ./crictl pods -o table
POD ID              CREATED             STATE               NAME                NAMESPACE           ATTEMPT
3f075e72dfa28       22 hours ago        Ready               virtlet-wcb8r       kube-system         0
ab863e4ae6f33       22 hours ago        Ready               kube-proxy-bqnhm    kube-system         0
[root@cloud-test2:/home/cloud]$ ./crictl images -o table
IMAGE                                                  TAG                 IMAGE ID            SIZE
busybox                                                latest              22c2dd5ee85dc       1.16MB
gcr.io/google_containers/busybox                       latest              e7d168d7db455       2.43MB
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64   1.14.5              459944ce8cc4f       41.4MB
gcr.io/google_containers/k8s-dns-kube-dns-amd64        1.14.5              512cd7425a731       49.4MB
gcr.io/google_containers/k8s-dns-sidecar-amd64         1.14.5              fed89e8b4248a       41.8MB
gcr.io/google_containers/kube-proxy-amd64              v1.10.5             32609f1b11ae7       97.9MB
gcr.io/google_containers/pause-amd64                   3.0                 99e59f495ffaa       747kB
k8s.gcr.io/pause-amd64                                 3.1                 da86e6ba6ca19       742kB
mirantis/virtlet                                       latest              9f76b554c615d       891MB
[root@cloud-test2:/home/cloud]$

@yanxuean
Copy link
Contributor Author

btw: Can we display podid in "crictl ps", Now we don't know which pod these container belong to.

@yanxuean
Copy link
Contributor Author

/retest

fix kubernetes-sigs#360
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
@feiskyer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 13, 2018
@Random-Liu
Copy link
Contributor

btw: Can we display podid in "crictl ps", Now we don't know which pod these container belong to.

SGTM

@Random-Liu Random-Liu merged commit 9d4dd73 into kubernetes-sigs:master Aug 13, 2018
@yanxuean yanxuean deleted the concise-imageid branch August 14, 2018 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

display 13 characters for imageid in "crictl ps"
4 participants