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

bugfix: only list container stats which are created by cri #2273

Merged
merged 1 commit into from
Sep 30, 2018

Conversation

YaoZengzeng
Copy link
Contributor

Signed-off-by: YaoZengzeng [email protected]

Ⅰ. Describe what this PR did

When CRI manager list container stats, filter the container which is not created by CRI.

Ⅱ. Does this pull request fix one issue?

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

No

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Sep 25, 2018

Codecov Report

Merging #2273 into master will increase coverage by <.01%.
The diff coverage is 42.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2273      +/-   ##
==========================================
+ Coverage   66.82%   66.82%   +<.01%     
==========================================
  Files         208      209       +1     
  Lines       16937    16963      +26     
==========================================
+ Hits        11318    11336      +18     
- Misses       4262     4268       +6     
- Partials     1357     1359       +2
Flag Coverage Δ
#criv1alpha1test 32.6% <0%> (+0.18%) ⬆️
#criv1alpha2test 35.77% <0%> (-0.34%) ⬇️
#integrationtest 39.41% <0%> (-0.12%) ⬇️
#nodee2etest 33.5% <11.53%> (+0.05%) ⬆️
#unittest 23.76% <30.76%> (+0.01%) ⬆️
Impacted Files Coverage Δ
cri/v1alpha1/cri.go 60.97% <0%> (-0.58%) ⬇️
cri/utils/utils.go 100% <100%> (ø)
cri/v1alpha2/cri.go 66.91% <33.33%> (-0.75%) ⬇️
daemon/logger/jsonfile/utils.go 71.54% <0%> (-1.63%) ⬇️
pkg/meta/store.go 62.5% <0%> (-1.57%) ⬇️
daemon/mgr/container_utils.go 83.13% <0%> (-1.21%) ⬇️
daemon/mgr/container.go 57.39% <0%> (-0.21%) ⬇️
ctrd/container.go 59.76% <0%> (ø) ⬆️
... and 6 more

@pouchrobot pouchrobot added kind/bug This is bug report for project size/XS labels Sep 25, 2018
@@ -822,7 +822,7 @@ func (c *CriManager) ContainerStats(ctx context.Context, r *runtime.ContainerSta
func (c *CriManager) ListContainerStats(ctx context.Context, r *runtime.ListContainerStatsRequest) (*runtime.ListContainerStatsResponse, error) {
opts := &mgr.ContainerListOption{All: true}
filter := func(c *mgr.Container) bool {
return true
return c.Config.Labels[containerTypeLabelKey] == containerTypeLabelContainer
Copy link
Contributor

Choose a reason for hiding this comment

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

only check labels here?

@YaoZengzeng YaoZengzeng force-pushed the filter-stats branch 6 times, most recently from 805664c to 3372df1 Compare September 25, 2018 10:56
@@ -822,6 +822,19 @@ func (c *CriManager) ContainerStats(ctx context.Context, r *runtime.ContainerSta
func (c *CriManager) ListContainerStats(ctx context.Context, r *runtime.ListContainerStatsRequest) (*runtime.ListContainerStatsResponse, error) {
opts := &mgr.ContainerListOption{All: true}
filter := func(c *mgr.Container) bool {
if c.Config.Labels[containerTypeLabelKey] != containerTypeLabelContainer {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a blank here to distinguish between filtering created by CRI Manager and filtering by request and it's beeter to write comments. WDTY?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@@ -814,6 +814,20 @@ func filterCRIContainers(containers []*runtime.Container, filter *runtime.Contai
return filtered
}

// matchLabelSelector returns true if labels cover selector.
func matchLabelSelector(selector, labels map[string]string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is uncoupled with runtime, maybe create a directory like utils under the cri directory for more public utility methods and move this funtion over. WDYT?

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, we could do it in another PR and move all the public utility methods to there.

Copy link
Contributor

Choose a reason for hiding this comment

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

@YaoZengzeng please put it in this PR. 😄 can you do this?

@YaoZengzeng YaoZengzeng force-pushed the filter-stats branch 4 times, most recently from 0baaf7b to d1262fc Compare September 26, 2018 09:34
@pouchrobot pouchrobot added size/L and removed size/XL labels Sep 26, 2018
@YaoZengzeng YaoZengzeng force-pushed the filter-stats branch 2 times, most recently from 76dbb51 to b85861a Compare September 26, 2018 09:38
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@fuweid fuweid merged commit 6719cc6 into AliyunContainerService:master Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants