Skip to content

Fix format_quantity precision and emit canonical decimal output#2625

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
sophotechlabs:fix/format-quantity-canonical-output
Jul 7, 2026
Merged

Fix format_quantity precision and emit canonical decimal output#2625
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
sophotechlabs:fix/format-quantity-canonical-output

Conversation

@archy-rock3t-cloud

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

For the milli, micro and nano suffixes, format_quantity built a Decimal from a float and returned imprecise values in scientific notation, which are not valid Kubernetes quantities. It now scales with Decimal(base) ** exponent and formats in plain decimal, matching parse_quantity, and no longer ignores quantize=Decimal(0).

Which issue(s) this PR fixes:

Fixes #2624

Does this PR introduce a user-facing change?

Fix format_quantity returning imprecise, non-canonical values for the milli, micro and nano suffixes, and ignoring quantize=Decimal(0).

Signed-off-by: Artem Muterko <artem@sopho.tech>
@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Jul 7, 2026
@kubernetes-prow kubernetes-prow Bot requested review from roycaihw and yliaog July 7, 2026 17:26
@kubernetes-prow kubernetes-prow Bot added 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. labels Jul 7, 2026

@roycaihw roycaihw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 7, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: archy-rock3t-cloud, roycaihw

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

The pull request process is described here

Details 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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2026
@kubernetes-prow kubernetes-prow Bot merged commit 6d86ea8 into kubernetes-client:master Jul 7, 2026
2 checks passed
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

format_quantity returns imprecise values for the milli, micro and nano suffixes

2 participants