Skip to content

Conversation

nmn3m
Copy link

@nmn3m nmn3m commented Jun 29, 2025

What this PR does / why we need it:

This PR updates metrics-server to display CPU usage in milli cores (e.g., 67m) instead of nano cores (e.g., 67131864n) in PodMetrics and NodeMetrics outputs. This makes the output more intuitive and aligns with Kubernetes conventions, where milli cores are the standard for CPU resource display.

Details:

  • Updates the scale in resource usage calculation from -9 (nano) to -3 (milli) in pkg/storage/types.go.
  • Adjusts all related unit tests to expect milli core values.
  • Improves user experience and consistency with other Kubernetes tools.
  • No API or data structure changes; only the display format is affected.

Which issue(s) this PR fixes:
Fixes #1669

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 29, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nmn3m
Once this PR has been reviewed and has the lgtm label, please assign serathius for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 29, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @nmn3m!

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
Copy link
Contributor

Hi @nmn3m. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 29, 2025
@googs1025
Copy link
Member

/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 Jun 30, 2025
@googs1025
Copy link
Member

This ci failed seems to be caused by changes. Can you solve it first? 😄

last: newMetricsPoint(start, start.Add(20*time.Millisecond), 500, 600),
prev: newMetricsPoint(start, start.Add(10*time.Millisecond), 300, 400),
wantResourceList: v1.ResourceList{v1.ResourceCPU: uint64Quantity(uint64(20000), resource.DecimalSI, -9),
wantResourceList: v1.ResourceList{v1.ResourceCPU: uint64Quantity(uint64(20000), resource.DecimalSI, -3),
Copy link
Member

Choose a reason for hiding this comment

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

Will this change affect the use of other downstream dependent parties? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

This change only affects the display format of CPU usage in the metrics-server output (from nano cores to milli cores). The underlying API, data structures, and values remain unchanged. This aligns with Kubernetes conventions and should not break downstream consumers, as the resource.Quantity type is still used and its string representation is now more user-friendly and consistent with other Kubernetes tools.

@nmn3m nmn3m force-pushed the fix-cpu-display-milli-cores branch from 5a30460 to 50312d2 Compare June 30, 2025 07:44
@nmn3m nmn3m requested a review from googs1025 June 30, 2025 22:12
…/NodeMetrics

This change updates the metrics-server to display CPU usage in milli cores (e.g., 67m) instead of nano cores (e.g., 67131864n) in PodMetrics and NodeMetrics outputs.

- Updates the scale in resource usage calculation from -9 (nano) to -3 (milli) in pkg/storage/types.go.
- Adjusts all related unit tests to expect milli core values.
- Improves user experience and aligns with Kubernetes conventions, where milli cores are the standard for CPU resource display.
- No API or data structure changes; only the display format is affected.
@nmn3m nmn3m force-pushed the fix-cpu-display-milli-cores branch from 147049c to 3cdc475 Compare June 30, 2025 22:32
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 30, 2025
@dgrisonnet
Copy link
Member

/assign

/cc @slashpai
Could you perhaps also have a look and double check if this won't break existing workflow?

@dgrisonnet
Copy link
Member

/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 10, 2025
@rexagod rexagod moved this to In Progress in SIG Instrumentation Aug 30, 2025
@rexagod rexagod moved this from In Progress to Needs Review (PR) or Response (Issue) in SIG Instrumentation Aug 30, 2025
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Status: Needs Review (PR) or Response (Issue)

Development

Successfully merging this pull request may close these issues.

CPU usage displayed by the PodMetrics and NodeMetrics tables does not seem intuitive

5 participants