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

fix: unnecessary resize volume error #364

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

andyzhangx
Copy link
Member

What type of PR is this?
/kind bug
What this PR does / why we need it:
fix: unnecessary resize volume error

this PR fixes the following resize volume error on Windows just right after disk format and mount succeeds on the node:

Warning  FailedMount             4s   kubelet                  MountVolume.MountDevice failed for volume "pvc-40e35e3f-2bf0-4adf-a27f-8a42f3a4ccf5" : rpc error: code = Internal desc = NodeStageVolume: could not resize volume 3 (\var\lib\kubelet\plugins\kubernetes.io\csi\disk.csi.azure.com\688ffc68ac8e6eb66ee127431af137461becbce570a6bfba581d3483ad7d778f\globalmount):  error resizing volume. cmd: Get-Volume -UniqueId "$Env:volumeID" | Get-Partition | Resize-Partition -Size 32195460608, output: Resize-Partition : Size Not Supported\r
 \r
Extended information:\r
The size of the extent is less than the minimum of 1MB.\r
 \r
Activity ID: {0ce86b89-e624-484f-a5aa-9810dccdf9b6}\r
At line:1 char:56\r
+ ...  "$Env:volumeID" | Get-Partition | Resize-Partition -Size 32195460608\r
+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
    + CategoryInfo          : NotSpecified: (StorageWMI:ROOT/Microsoft/.../MSFT_Partition) [Resize-Partition], CimExce \r
   ption\r
    + FullyQualifiedErrorId : StorageWMI 4097,Resize-Partition\r
  • root cause

we use Get-Volume -UniqueId \"$Env:volumeID\" | Get-partition | Get-PartitionSupportedSize | Select SizeMax
to get the targetVolumeSize, and we use following command to get the currentVolumeSize

(Get-Volume -UniqueId \"$Env:volumeID\\" | Get-partition).Size

if targetVolumeSize > currentVolumeSize, then we should resize.

But as following example, you could see for a 29.98 GB disk, just right after it's formatted, targetVolumeSize is always bigger than currentVolumeSize (just 1MB bigger), so resize operation would always happen. I think this is a bug, only if targetVolumeSize > currentVolumeSize + 1GB, then we should perform resize operation, in that case, NodeStageVolume should succeed.

(Get-Disk -Number 3 | Get-Partition | Get-Volume).UniqueId
PS C:\> Get-Volume -UniqueId "\\?\Volume{ccfda246-2790-4cf3-9fbf-37a62e1f9f6d}\" | Get-partition
   DiskPath: \\?\scsi#disk&ven_msft&prod_virtual_disk#6&23db5f40&0&000001#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                                           Size Type
---------------  ----------- ------                                                           ---- ----
2                G           16777216                                                     29.98 GB Basic

PS C:\> (Get-Volume -UniqueId "\\?\Volume{ccfda246-2790-4cf3-9fbf-37a62e1f9f6d}\" | Get-partition).Size
32194428928
PS C:\> Get-Volume -UniqueId "\\?\Volume{ccfda246-2790-4cf3-9fbf-37a62e1f9f6d}\" | Get-partition | Get-PartitionSupportedSize | Select SizeMax

    SizeMax
    -------
32195460608

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix: unnecessary resize volume error

@k8s-ci-robot k8s-ci-robot 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 Dec 16, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 16, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 16, 2024
Copy link
Member

@mauriciopoppe mauriciopoppe left a comment

Choose a reason for hiding this comment

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

Thank you for finding the root cause! We've seen this as well occasionally in GKE.

@mauriciopoppe
Copy link
Member

Is the description correct? The implementation says 100MB in a comment but 1GB in the description.

@msau42
Copy link
Contributor

msau42 commented Dec 16, 2024

Awesome, we'll also want to backport this to csi proxy v1 was well.

@mauriciopoppe
Copy link
Member

master is CSI Proxy v1 but agreed this should go against the branch https://github.com/kubernetes-csi/csi-proxy/tree/library-development as well.

@andyzhangx
Copy link
Member Author

Is the description correct? The implementation says 100MB in a comment but 1GB in the description.

delta of the minimum size expand should be at least 1GB, so 100MB is ok.

pkg/os/volume/api.go Outdated Show resolved Hide resolved
@andyzhangx andyzhangx force-pushed the fix-unnecessary-resize-error branch from d444742 to 3871187 Compare December 18, 2024 03:55
@mauriciopoppe
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 18, 2024
@k8s-ci-robot k8s-ci-robot merged commit ad5f830 into master Dec 18, 2024
14 checks passed
@andyzhangx
Copy link
Member Author

/cherrypick library-development

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants