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

Filter out duplicated container stats #54606

Conversation

miaoyq
Copy link

@miaoyq miaoyq commented Oct 26, 2017

What this PR does / why we need it:

Which issue this PR fixes *
fixes #53514

Special notes for your reviewer:

/cc @Random-Liu

Signed-off-by: Yanqiang Miao miao.yanqiang@zte.com.cn

@k8s-ci-robot
Copy link
Contributor

@miaoyq: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 26, 2017
@miaoyq miaoyq force-pushed the filter-out-duplicated-container-stats branch from 9f1fcca to 365c2e7 Compare October 26, 2017 06:54
@xiangpengzhao
Copy link
Contributor

/release-note-none
/ok-to-test

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 26, 2017
@dashpole
Copy link
Contributor

based on #53514 (comment), we only want to exclude terminated containers if they are duplicated. I.E. if we have stats for another container in that pod with the same name.

@miaoyq
Copy link
Author

miaoyq commented Oct 26, 2017

@dashpole Got it. Thank you for reminding me. : )

@miaoyq miaoyq force-pushed the filter-out-duplicated-container-stats branch 2 times, most recently from 1e210f6 to d4125b5 Compare October 30, 2017 12:08
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 1, 2017
@miaoyq
Copy link
Author

miaoyq commented Nov 1, 2017

@dashpole I have updated the code and add unit test for this, PTAL, Thanks. :)

}
i := 0
for ; i < len(refs); i++ {
if containerStatsMap[refs[i].Id].Cpu != nil || containerStatsMap[refs[i].Id].Memory != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ever possible to have more than one container in refs running at once? Why cant we just take the last element from the list?

Copy link
Author

Choose a reason for hiding this comment

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

@dashpole Thanks for review. I have the same doubts, but cadvisor stats do like this.
Is there any different between CRI stats and cadvisor stats? ping @yguo0905

Copy link
Author

Choose a reason for hiding this comment

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

ping @yguo0905
Could you please help us solve our doubts, thanks so much. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

It would allow us to detect the error case where multiple containers with the same name are active at the same time. See #47853 (comment).

@Random-Liu Random-Liu self-assigned this Nov 7, 2017
@miaoyq
Copy link
Author

miaoyq commented Nov 7, 2017

/assign @Random-Liu

@yguo0905
Copy link
Contributor

yguo0905 commented Nov 7, 2017

Let's wait for the answer to #53514 (comment).

If we'd like to do the filtering for cadvisor and cri stats, is it possible to have a single removeTerminatedContainer works for both cases?

@miaoyq
Copy link
Author

miaoyq commented Nov 9, 2017

Thanks @yguo0905 , I find it's hard to have a single removeTerminatedContainer works for both cases, because the objects filtered are different about cadvisor and cri.
If you have good ideas, please let me know. Thanks :-)

Copy link
Member

@Random-Liu Random-Liu left a comment

Choose a reason for hiding this comment

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

LGTM other than the comments.

})
for _, container := range containers {
// Filter out the container that isn't managed by a Pod
if container.PodSandboxId == "" {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can assume that all container stats returned by CRI container runtime are for kubelet. If not, it is an error.

Copy link
Author

@miaoyq miaoyq Nov 17, 2017

Choose a reason for hiding this comment

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

Do we delete this logic? or return an error here?

Copy link
Member

Choose a reason for hiding this comment

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

I think delete the logic is fine. :)

continue
}
i := 0
for ; i < len(refs); i++ {
Copy link
Member

Choose a reason for hiding this comment

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

I prefer check container state and only keep running containers, since we've already got container state.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

It seems that this is not addressed.

Copy link
Author

Choose a reason for hiding this comment

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

I have not got what you mean clearly, done.

@miaoyq miaoyq force-pushed the filter-out-duplicated-container-stats branch 3 times, most recently from 23c193a to 1b9b2f2 Compare November 17, 2017 05:54
@miaoyq
Copy link
Author

miaoyq commented Nov 17, 2017

/test pull-kubernetes-node-e2e

result = append(result, refs[0])
continue
}
for i := 0; i < len(refs); i++ {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add one more logic? If no running container found, we should add the latest container.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for this, have added, PTAL, :-)

@Random-Liu
Copy link
Member

LGTM with one last nit.

@Random-Liu Random-Liu added this to the v1.9 milestone Nov 17, 2017
@Random-Liu Random-Liu added the kind/bug Categorizes issue or PR as related to a bug. label Nov 17, 2017
@xiangpengzhao
Copy link
Contributor

/priority important-soon
/sig node
/retest

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Nov 17, 2017
@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request Needs Approval

@Random-Liu @dashpole @miaoyq @tmrts @kubernetes/sig-node-misc

Action required: This pull request must have the status/approved-for-milestone label applied by a SIG maintainer. If the label is not applied within 6 days, the pull request will be moved out of the v1.9 milestone.

Pull Request Labels
  • sig/node: Pull Request will be escalated to these SIGs if needed.
  • priority/important-soon: Escalate to the pull request owners and SIG owner; move out of milestone after several unsuccessful escalation attempts.
  • kind/bug: Fixes a bug discovered during the current release.
Help

@miaoyq miaoyq force-pushed the filter-out-duplicated-container-stats branch from 1b9b2f2 to 11cf390 Compare November 18, 2017 01:44
Yanqiang Miao added 2 commits November 18, 2017 09:51
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
@Random-Liu
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 Nov 18, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: miaoyq, Random-Liu

Associated issue: 53514

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 18, 2017
@Random-Liu
Copy link
Member

@miaoyq Thanks for working on this!

@xiangpengzhao
Copy link
Contributor

/retest

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. milestone/needs-approval priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. 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.

CRI: Clearly define the expectation of Summary API and CRI Stats
8 participants