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

kernel bug lead to incorrect cpu usage #1300

Conversation

sleepyzhang
Copy link
Contributor

in one case,metrics-server will respons incorrect cpu usage,detailed description is as follows:
A StatefulSet pod named pod-0 used to run on a node named node1, this pod is then scheduled to run on node2,node1 has a kernel bug that causes the resource usage information of the pod-0 is stored,so when metrics-server pulls datas,which can pull pod-0 datas on node1 and node2, and drop node2's data, then when hpa controller gets pod-0 cpu usage will get a very large value,eg:pod-0 ran in node1 3 days ago,which used cpu accumulate 518400,and then pod-0 now running in node2 and used cpu accumulate 30, in this case, the calculated cpu usage is very large,the calcute way is described as follows:

  1. subValue: 518400 - 30
  2. windows: time.Now().Add(-324time.Hour).Sub(time.Now())
  3. cpuUsage: subValue / windows = (518400 - 30) / time.Now().Add(-324time.Hour).Sub(time.Now()).Seconds()
  4. res = uint64Qunatity(uint64(cpuUsage), resource.DecimalSI, -9)
  5. res is 18446744074
    so when calcute cpu usage,needing add a judge about data's collected timestamp

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 26, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 26, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @sleepyzhang!

It looks like this is your first PR to kubernetes-sigs/metrics-server 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/metrics-server has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 26, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @sleepyzhang. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 26, 2023
@serathius
Copy link
Contributor

/lgtm
/approve

Can you backport to v0.6?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 26, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: serathius, sleepyzhang

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 26, 2023
@serathius
Copy link
Contributor

/hold

Please sign the CLA and add a test.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2023
@dashpole
Copy link

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jul 27, 2023
@sleepyzhang sleepyzhang force-pushed the fixCpuUsageComputationException branch from f0c375b to 82a7323 Compare July 30, 2023 04:15
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 30, 2023
@sleepyzhang
Copy link
Contributor Author

/lgtm /approve

Can you backport to v0.6?

/lgtm /approve

Can you backport to v0.6?

@serathius Does that mean I should mention a pr based on v0.6?

@sleepyzhang
Copy link
Contributor Author

/hold

Please sign the CLA and add a test.

@serathius How do i add a test?

@serathius
Copy link
Contributor

/retest

@serathius
Copy link
Contributor

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 31, 2023
@serathius
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 31, 2023
@serathius
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 31, 2023
@serathius
Copy link
Contributor

/retest

@k8s-ci-robot k8s-ci-robot merged commit 1693eb0 into kubernetes-sigs:master Jul 31, 2023
12 checks passed
yangjunmyfm192085 added a commit to yangjunmyfm192085/metrics-server that referenced this pull request Aug 2, 2023
yangjunmyfm192085 added a commit to yangjunmyfm192085/metrics-server that referenced this pull request Aug 2, 2023
k8s-ci-robot added a commit that referenced this pull request Aug 2, 2023
[release-0.6] cherrypick #1300 kernel bug lead to incorrect cpu usage
Cloudzp pushed a commit to Cloudzp/metrics-server that referenced this pull request Dec 26, 2023
Cloudzp added a commit to Cloudzp/metrics-server that referenced this pull request Dec 26, 2023
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants