Skip to content

fix(apimachinery): allow 19-digit quantities to support math.MaxInt64#135956

Open
Kesavaraja67 wants to merge 1 commit intokubernetes:masterfrom
Kesavaraja67:fix-resource-parse-maxint
Open

fix(apimachinery): allow 19-digit quantities to support math.MaxInt64#135956
Kesavaraja67 wants to merge 1 commit intokubernetes:masterfrom
Kesavaraja67:fix-resource-parse-maxint

Conversation

@Kesavaraja67
Copy link

@Kesavaraja67 Kesavaraja67 commented Dec 27, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes a precision bottleneck in the resource quantity parser where 19-digit numbers, such as math.MaxInt64, failed the base-10 fast-path check.

By increasing the digit threshold from 18 to 19 and adding a boundary check using strconv.ParseUint, the parser now correctly supports the full range of int64 values. This prevents parsing failures and avoids unnecessary fallbacks to slower parsing paths for the maximum representable integer in Go (9,223,372,036,854,775,807).

Which issue(s) this PR is related to:

Fixes #135487

Special notes for your reviewer:

This change has been verified using go test and go vet. In particular, math.MaxInt64 now parses successfully within the resource package:

go test -v ./staging/src/k8s.io/apimachinery/pkg/api/resource/

Does this PR introduce a user-facing change?

Fixed a bug in the resource quantity parser that prevented quantities equal to math.MaxInt64 from being parsed correctly.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 27, 2025
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Kesavaraja67 / name: Kesavaraja M (2b57ebf)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 27, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

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

Welcome @Kesavaraja67!

It looks like this is your first PR to kubernetes/kubernetes 🎉. 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/kubernetes 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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 27, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @Kesavaraja67. Thanks for your PR.

I'm waiting for a github.com 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.

Details

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 sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 27, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. 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. labels Dec 27, 2025
@Kesavaraja67 Kesavaraja67 force-pushed the fix-resource-parse-maxint branch from cf52e4b to 2b57ebf Compare December 27, 2025 13:52
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 27, 2025
@Kesavaraja67
Copy link
Author

Hi @thockin @derekwaynecarr, I have fixed the CLA and release-note formatting issues. This PR is now ready for review and testing. Could you please take a look and /ok-to-test if this is ready for the CI suite? Thank you!

@Kesavaraja67
Copy link
Author

/sig api-machinery
/sig apps

@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Dec 28, 2025
@Kesavaraja67
Copy link
Author

/sig api-machinery

@dims
Copy link
Member

dims commented Dec 29, 2025

is this theoretical or a real world scenario?

@Kesavaraja67
Copy link
Author

Hi @dims! To be honest, I found this through code analysis and testing while looking at the parser, so it's 'theoretical' in the sense that I haven't seen a specific bug report for it yet.

However, I realized that while math.MaxInt64 is a perfectly valid int64 value, the parser's 18-digit fast-path check effectively blocks it. Since Kubernetes is increasingly used for massive resource quantities (like bytes for very large storage), I figured it was better to fix this logic gap now before it becomes a real-world production issue for someone.

@seans3
Copy link
Contributor

seans3 commented Jan 8, 2026

/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 Jan 8, 2026
@k8s-ci-robot
Copy link
Contributor

@Kesavaraja67: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-linter-hints 2b57ebf link false /test pull-kubernetes-linter-hints
pull-kubernetes-verify 2b57ebf link true /test pull-kubernetes-verify
pull-kubernetes-e2e-gce 2b57ebf link true /test pull-kubernetes-e2e-gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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. I understand the commands that are listed here.

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. kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

resource.MustParse fails to parse quantities near math.MaxInt64

4 participants