Skip to content

Conversation

arsiesys
Copy link
Contributor

@arsiesys arsiesys commented Jul 9, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:
This PR updates the Hyperdisk balanced attach limits to align with the latest GCP documentation for Gen4 machine families (C4, C4D, N4, and C4A).
Previously, a single generic map was used, which did not reflect the correct per-family attach limits for newer machine types.

Key changes:

  • Adds separate Hyperdisk attach limit maps for C4, C4D, N4, and C4A machines.
  • Updates the attach limit calculation logic to use the appropriate map based on the machine type prefix.
  • Updates unit tests to cover new machine type mappings and verify correct limits.

This fixes inaccurate attach limits for Gen4 machines, ensuring compliance with the [official GCP guidance](https://cloud.google.com/compute/docs/general-purpose-machines).

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

  • Please verify the machine type prefixes and limit values match the official GCP tables.
fix: Updated Hyperdisk balanced attach limits for C4, C4D, N4, and C4A machine families to match current GCP documentation.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 9, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @arsiesys!

It looks like this is your first PR to kubernetes-sigs/gcp-compute-persistent-disk-csi-driver 🎉. 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/gcp-compute-persistent-disk-csi-driver 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 9, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @arsiesys. 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 9, 2025
@sunnylovestiramisu
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 9, 2025
if len(limitMap) > 0 {
return limitMap[len(limitMap)-1].value
}
return 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not think we should return 0 here, maybe use the default volumeLimitSmall.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can return a static 15 as the constant is declared in node.go.
Or, I could move the constant from node.go to the common package, let me know which path we prefer.

@arsiesys arsiesys force-pushed the fix/hyperdisk-limits branch from 7b49535 to 6df040f Compare July 9, 2025 16:20
@sunnylovestiramisu
Copy link
Contributor

/test pull-gcp-compute-persistent-disk-csi-driver-e2e-windows-2022

@sunnylovestiramisu
Copy link
Contributor

/assgn @mattcary

return a4HyperdiskLimit, nil
}
}
if strings.HasPrefix(machineType, "x4-") {
Copy link
Contributor

@sunnylovestiramisu sunnylovestiramisu Jul 9, 2025

Choose a reason for hiding this comment

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

Why moved this outside? Because if it is inside the machineType is x4 or a4 it does not need to go through the loop. But on the other hand it does not matter so much in the real world

Copy link
Contributor Author

@arsiesys arsiesys Jul 9, 2025

Choose a reason for hiding this comment

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

You're right! Moving these checks outside was what I though could be a performance optimisation.

Since x4/a4 machine types don't match any of the gen4 prefixes (c4a-, c4-, n4-, c4d-), keeping them inside the loop means we'd unnecessarily check them 4 times (once per iteration) before ultimately returning the correct limit.

By moving them outside:

  • gen4 machines: Exit early when matched, never reaching these checks
  • Other machines: Only check x4/a4 once at the end

This reduces string comparisons from up to 12 (4 iterations × 3 checks) to at most 6 (4 gen4 + x4 + a4).

I also considered that x4 and a4 may be less frequently used than the ones in the loop. I will put it back if you think it would be better or not the subject of the current PR (would be understandable).

@arsiesys arsiesys force-pushed the fix/hyperdisk-limits branch from 6df040f to d1ae089 Compare July 9, 2025 23:41
@sunnylovestiramisu
Copy link
Contributor

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arsiesys, sunnylovestiramisu

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 10, 2025
@k8s-ci-robot k8s-ci-robot merged commit cb6ce0f into kubernetes-sigs:master Jul 10, 2025
9 checks passed
@sunnylovestiramisu
Copy link
Contributor

/cherry-pick release-1.20

@k8s-infra-cherrypick-robot

@sunnylovestiramisu: #2127 failed to apply on top of branch "release-1.20":

Applying: fix: update Hyperdisk attach limits to match GCP documentation for Gen4 machines
Using index info to reconstruct a base tree...
M	pkg/gce-pd-csi-driver/node.go
M	pkg/gce-pd-csi-driver/node_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/gce-pd-csi-driver/node_test.go
CONFLICT (content): Merge conflict in pkg/gce-pd-csi-driver/node_test.go
Auto-merging pkg/gce-pd-csi-driver/node.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 fix: update Hyperdisk attach limits to match GCP documentation for Gen4 machines

In response to this:

/cherry-pick release-1.20

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.

sunnylovestiramisu pushed a commit to sunnylovestiramisu/gcp-compute-persistent-disk-csi-driver that referenced this pull request Jul 10, 2025
…imits

fix: update Hyperdisk attach limits to match GCP documentation for Gen4
machines
sunnylovestiramisu pushed a commit to sunnylovestiramisu/gcp-compute-persistent-disk-csi-driver that referenced this pull request Jul 10, 2025
…imits

fix: update Hyperdisk attach limits to match GCP documentation for Gen4
machines
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

4 participants