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

Collect and expose runtime's image storage usage via Kubelet's /stats/summary endpoint #23595

Merged
merged 1 commit into from
Apr 26, 2016

Conversation

vishh
Copy link
Contributor

@vishh vishh commented Mar 29, 2016

This information is useful to users since docker images are typically not stored on the root filesystem.

Kubelet will also consume this feature in the future to decide is evicting images will help with disk usage on the nodes.

cc @kubernetes/sig-node

@dchen1107 dchen1107 self-assigned this Mar 29, 2016
@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 29, 2016
@k8s-bot
Copy link

k8s-bot commented Mar 29, 2016

GCE e2e build/test passed for commit c8c7c82971899545d5a4302b53c62580f2a945b1.

@vishh
Copy link
Contributor Author

vishh commented Mar 31, 2016

@timstclair: Can you do an initial review?

@vishh vishh force-pushed the image-accounting branch from c8c7c82 to 008b522 Compare March 31, 2016 21:11
@k8s-bot
Copy link

k8s-bot commented Mar 31, 2016

GCE e2e build/test passed for commit 008b5221cfcb0f0297b3ff83a5f3fb27714b9eb2.

@@ -31,7 +31,7 @@
"/hyperkube",
"apiserver",
"--service-cluster-ip-range=10.0.0.1/24",
"--insecure-bind-address=127.0.0.1",
"--insecure-bind-address=0.0.0.0",

Choose a reason for hiding this comment

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

This looks unrelated? Also, doesn't this expose the insecure outside the local machine? Intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. Reverting this..

@timstclair
Copy link

Finished review pass.

@yujuhong
Copy link
Contributor

Kubelet will also consume this feature in the future to decide is evicting images will help with disk usage on the nodes.

Is the intention to look at the total size to see if it's even worth evicting some images? The size of all images won't help decide what image to evict.

@yujuhong
Copy link
Contributor

/cc @Random-Liu, this will affect your PR #23506 to switch to using docker engine-api

@Random-Liu
Copy link
Member

@yujuhong Thanks. This needs a little rebase after #23506 get merged. It shouldn't be hard (Hopefully :P)

@vishh
Copy link
Contributor Author

vishh commented Mar 31, 2016

Is the intention to look at the total size to see if it's even worth evicting some images? The size of all images won't help decide what image to evict.

Yes. In a separate PR, I plan on cleaning up the image GC logic as well.

@vishh vishh force-pushed the image-accounting branch from 008b522 to 0c4b18e Compare March 31, 2016 23:32
@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 31, 2016
@vishh
Copy link
Contributor Author

vishh commented Mar 31, 2016

@timstclair: Thanks for the review. Addressed all comments.

@k8s-bot
Copy link

k8s-bot commented Apr 1, 2016

GCE e2e build/test passed for commit 0c4b18e2a38198ee0604f56f6c212412ca5aac6b.

@vishh vishh assigned timstclair and unassigned dchen1107 Apr 8, 2016
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2016
@vishh vishh force-pushed the image-accounting branch from 712fbec to 7faccbb Compare April 22, 2016 23:08
@vishh
Copy link
Contributor Author

vishh commented Apr 22, 2016

@timstclair Just did a rebase. PTAL when you get a chance.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 22, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 22, 2016

GCE e2e build/test failed for commit 7faccbb2ef1d8cce1c9cacb4eb23355e22f2bfd0.

Please reference the list of currently known flakes when examining this failure. If you request a re-test, you must reference the issue describing the flake.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 24, 2016
if !imageMap.Has(key) {
ret.TotalStorageBytes += uint64(layer.Size)
}
imageMap.Insert(key)

Choose a reason for hiding this comment

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

Doesn't this mean we'll only add the first layer for each image? Is that intentional?

Choose a reason for hiding this comment

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

Do the unit tests still pass with this? If it's not intentional and the tests do still pass, please update the tests to fail on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. history contains all the layers for an image. Let's look at an example:

$ docker history bef5c7a893fd
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
bef5c7a893fd        4 days ago          /bin/sh -c #(nop) ENTRYPOINT ["/usr/bin/cadvi   0 B                 
5714946567e8        4 days ago          /bin/sh -c #(nop) EXPOSE 8080/tcp               0 B                 
d5092c6dfc49        4 days ago          /bin/sh -c #(nop) ADD file:5047bc1f57482bfdc9   23.75 MB            
fb1790e81294        4 days ago          /bin/sh -c apk add --update ca-certificates d   19.99 MB            
3d239f12c85f        4 weeks ago         /bin/sh -c #(nop) ENV GLIBC_VERSION=2.23-r1     0 B                 
86fbae24586c        4 weeks ago         /bin/sh -c #(nop) MAINTAINER dengnan@google.c   0 B                 
342c0650e86b        7 weeks ago         /bin/sh -c #(nop) ADD file:cda4b589f22e7984e3   5.258 MB 

For this example, history would be a list of layer elements where each line in the output above matches a layer.
The key for each layer will be mostly unique, expect for the <missing> case, which is handled by using the Created By field. That field is expected to contain the command that was run for that layer and hence it must be unique.

Am I misreading my code?

Choose a reason for hiding this comment

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

Ah, sorry, my mistake. I misread key as the image key, not the layer key. What you have makes sense.

@timstclair
Copy link

LGTM, needs rebase.

@timstclair timstclair added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 25, 2016
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 25, 2016
@vishh vishh changed the title Collect and expose runtime's image storage usage Collect and expose runtime's image storage usage vis Kubelet's /stats/summary endpoint Apr 25, 2016
@vishh vishh changed the title Collect and expose runtime's image storage usage vis Kubelet's /stats/summary endpoint Collect and expose runtime's image storage usage via Kubelet's /stats/summary endpoint Apr 25, 2016
@vishh vishh added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Apr 25, 2016
add image fs info to summary stats API.
Adding node e2e test for image stats.

Signed-off-by: Vishnu kannan <vishnuk@google.com>
@vishh vishh force-pushed the image-accounting branch from 7faccbb to e566948 Compare April 25, 2016 23:00
@vishh
Copy link
Contributor Author

vishh commented Apr 25, 2016

Just did a rebase. I'm adding the lgtm label again. FYI @timstclair

@vishh vishh added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 25, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 25, 2016
@k8s-bot
Copy link

k8s-bot commented Apr 25, 2016

GCE e2e build/test passed for commit e566948.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Apr 26, 2016

GCE e2e build/test passed for commit e566948.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@Random-Liu
Copy link
Member

Random-Liu commented Apr 30, 2016

Just FYI, the perfdash shows that this PR increases the runtime CPU usage by about 0.05 cores (from 0.3 cores to 0.35 cores).
It is not significant, but it would be good to track it here so that in the future if we want to do some performance optimization, we can revisit this. :)

@yujuhong
Copy link
Contributor

yujuhong commented May 2, 2016

Just FYI, the perfdash shows that this PR increases the runtime CPU usage by about 0.05 cores (from 0.3 cores to 0.35 cores).

What build was this? I couldn't find it.

@Random-Liu
Copy link
Member

@yujuhong
Copy link
Contributor

yujuhong commented May 2, 2016

IIUC, the PR lists the images and invoke ImageHistory call for each image. We should be able to cache the output, and only call ImageHistory for images we haven't seen before.

@Random-Liu
Copy link
Member

@yujuhong Agree. We could file an issue for this, :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.