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

enhance: cache image size and oci image spec in pouchd #2301

Merged
merged 1 commit into from
Oct 10, 2018
Merged

enhance: cache image size and oci image spec in pouchd #2301

merged 1 commit into from
Oct 10, 2018

Conversation

fuweid
Copy link
Contributor

@fuweid fuweid commented Oct 9, 2018

Signed-off-by: Wei Fu fuweid89@gmail.com

Ⅰ. Describe what this PR did

when the containerd manages many big images, the pouchd ListImage will
consume a lot of CPU resources caused by containerd.Content.Read stream
grpc call.

In the k8s, the kubelet gc image manager will send the ListImage request
every 30s. If the containerd consumes too many CPU resources, it will
impact the container. Therefore, pouchd needs to cache the data.

Ⅱ. Does this pull request fix one issue?

NONE

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

no need

Ⅳ. Describe how to verify it

CI

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Oct 9, 2018

Codecov Report

Merging #2301 into master will increase coverage by 0.22%.
The diff coverage is 81.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2301      +/-   ##
==========================================
+ Coverage   66.61%   66.84%   +0.22%     
==========================================
  Files         211      211              
  Lines       17195    17205      +10     
==========================================
+ Hits        11455    11500      +45     
+ Misses       4337     4308      -29     
+ Partials     1403     1397       -6
Flag Coverage Δ
#criv1alpha1test 32.29% <81.13%> (+0.3%) ⬆️
#criv1alpha2test 35.7% <81.13%> (+0.04%) ⬆️
#integrationtest 39.85% <81.13%> (+0.26%) ⬆️
#nodee2etest 33.09% <67.92%> (+0.07%) ⬆️
#unittest 23.46% <1.88%> (-0.01%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/image.go 57.93% <72.72%> (+0.94%) ⬆️
daemon/mgr/image_store.go 97.76% <95%> (+8.33%) ⬆️
apis/server/utils.go 61.9% <0%> (-4.77%) ⬇️
daemon/mgr/snapshot.go 89.85% <0%> (-4.35%) ⬇️
daemon/logger/jsonfile/utils.go 71.54% <0%> (-1.63%) ⬇️
cri/v1alpha2/cri_wrapper.go 61.2% <0%> (-1.2%) ⬇️
cri/v1alpha2/cri.go 66.03% <0%> (-0.59%) ⬇️
daemon/mgr/container.go 57.43% <0%> (+0.4%) ⬆️
cri/v1alpha1/cri.go 61.03% <0%> (+0.64%) ⬆️
ctrd/container.go 59.28% <0%> (+0.95%) ⬆️
... and 6 more

@@ -62,6 +65,16 @@ type imageStore struct {

// primaryRefsIndexByID stores primay references, index by image ID
primaryRefsIndexByID map[digest.Digest]referenceMap

// cache ociImage to avoid open stream grpc to containerd, index by digest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add the consequence which will happen if not do the cache thing.

when the containerd manages many big images, the pouchd ListImage will
consume a lot of CPU resources caused by containerd.Content.Read stream
grpc call.

In the k8s, the kubelet gc image manager will send the ListImage request
every 30s. If the containerd consumes too many CPU resources, it will
impact the container. Therefore, pouchd needs to cache the data.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
if err != nil {
if err == errCtrdImageInfoNotExist {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the image not found in local store, should we check it from containerd?

// RemoveAllReferences removes all the reference by the given imageID.
func (store *imageStore) RemoveAllReferences(id digest.Digest) error {
// ListCtrdImageInfo returns all the CtrdImageInfo.
func (store *imageStore) ListCtrdImageInfo() []CtrdImageInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

support filter later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

YES!

// containerd.RemoveImage must success. so if the localStore has been
// remove all the primary references, we should clear the CtrdImageInfo
// cache.
defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whether we should remove the cache image info when the image has been succeeded?

@HusterWan
Copy link
Contributor

I have discuss with @fuweid offline and think this PR is LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Oct 10, 2018
@HusterWan HusterWan merged commit a6d6519 into AliyunContainerService:master Oct 10, 2018
@fuweid fuweid deleted the enhance_cache_oci_image_info branch October 11, 2018 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/test LGTM one maintainer or community participant agrees to merge the pull reuqest. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants