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

Update Volume API #138

Merged
merged 29 commits into from
May 31, 2021
Merged

Conversation

mauriciopoppe
Copy link
Member

@mauriciopoppe mauriciopoppe commented May 12, 2021

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind feature

What this PR does / why we need it:

Updates the Volume v1beta3 API according to the API review in #130, in addition to that:

  • Regenerated the pb.go file for the changes I made in the proto file and client/groups.volume/v1beta3/client_generated.go, I synced these changes back to the vendor folder too so that the server can use them
  • Updated the host wrapper in the server to use the new signatures
  • I moved the host interface API to internal/os/volume/api.go because it belongs here, previously the owner was the wrapper, this fixed an issue where the host API wasn't fulfilling any interface and generated problems while renaming things
  • Updated integrationtests/volume_test.go to use diskNumber (uint32) instead of diskID (string)
  • Regenerated the internal/server/volume/internal/v1X files, the older APIs are incompatible with the new parameters in the v1beta3 proto file, I didn't want to touch the autogenerated for older APIs but unfortunately I can't compile the code if I don't make these changes
  • Regenerated the internal/server/volume/internal/v1X files, for pre v1beta3 versions I added more conversion fields to conversion.go, that way the internal server representation of the requests from any API is the same (no special cases for pre v1beta3 APIs aside from the pre v1beta3 methods)
  • I updated the tests, there was one test that was checking an invalid case with an empty diskID but because we're using diskNumber I removed this test and instead I'm checking for negative values

Which issue(s) this PR fixes:

Fixes #130

Does this PR introduce a user-facing change?:

Updated the v1beta3 Volume API because of an API review, changes are summarized in #130 

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 12, 2021
@k8s-ci-robot k8s-ci-robot requested review from andyzhangx and kkmsft May 12, 2021 21:22
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 12, 2021
@mauriciopoppe mauriciopoppe force-pushed the volume-api-changes branch 2 times, most recently from 8d99202 to fbb215a Compare May 12, 2021 21:57
@mauriciopoppe mauriciopoppe marked this pull request as ready for review May 12, 2021 22:11
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 12, 2021
@mauriciopoppe
Copy link
Member Author

/uncc @kkmsft @andyzhangx
/cc @ddebroy @msau42 @jingxu97

@k8s-ci-robot k8s-ci-robot requested review from ddebroy, jingxu97 and msau42 and removed request for andyzhangx and kkmsft May 12, 2021 22:12
@mauriciopoppe
Copy link
Member Author

I need to change disk number to uint32
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 14, 2021
@mauriciopoppe
Copy link
Member Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 14, 2021
@mauriciopoppe mauriciopoppe force-pushed the volume-api-changes branch 2 times, most recently from fcfd54c to 9409e62 Compare May 14, 2021 21:04
pohly added a commit to pohly/csi-proxy that referenced this pull request May 21, 2021
a1e1127 Merge pull request kubernetes-csi#139 from pohly/kind-for-kubernetes-latest
1c0fb09 prow.sh: use KinD main for latest Kubernetes
1d77cfc Merge pull request kubernetes-csi#138 from pohly/kind-update-0.10
bff2fb7 prow.sh: KinD 0.10.0

git-subtree-dir: release-tools
git-subtree-split: a1e11275b5a4febd6ad21beeac730e22c579825b
@mauriciopoppe mauriciopoppe force-pushed the volume-api-changes branch 2 times, most recently from b4244fd to ddb4140 Compare May 24, 2021 21:15
@mauriciopoppe
Copy link
Member Author

/unhold

I've run the volume e2e tests in a GCE windows instance with Hyper-V enabled, these are the results:

PS C:\Users\mauriciopoppe\go\src\github.com\kubernetes-csi\csi-proxy> go clean -testcache
PS C:\Users\mauriciopoppe\go\src\github.com\kubernetes-csi\csi-proxy> go test -v .\integrationtests\ -run TestVolumeAPIs
=== RUN   TestVolumeAPIs
=== RUN   TestVolumeAPIs/E2E
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c mkdir C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\mount-75"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\disk-25.vhdx -SizeBytes 1073741824"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Mount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\disk-25.vhdx"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c (Get-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\disk-25.vhdx).DiskNumber"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Initialize-Disk -Number 14 -PartitionStyle GPT"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-Partition -DiskNumber 14 -UseMaximumSize"
    volume_test.go:407: VolumeId \\?\Volume{1abe379c-e431-4c8a-bb48-35bbe8ea30cd}\
    volume_test.go:253: Checking that the size is inside the bounds: 1052770304 < (actual) 1056894976 < 1073741824
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Resize-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\disk-25.vhdx -SizeBytes 2113789952"
    volume_test.go:446: Attempt to resize volume from sizeBytes=1056894976 to sizeBytes=1585342464
    volume_test.go:253: Checking that the size is inside the bounds: 1564370944 < (actual) 1585340416 < 1585342464
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Dismount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\disk-25.vhdx"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rm C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\disk-25.vhdx"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\mount-75"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-57.csi.io\\"
=== RUN   TestVolumeAPIs/NegativeDiskTests
=== RUN   TestVolumeAPIs/NegativeVolumeTests
=== RUN   TestVolumeAPIs/VolumeAPICompatibilityTests
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c mkdir C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\mount-66"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\disk-82.vhdx -SizeBytes 1073741824"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Mount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\disk-82.vhdx"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c (Get-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\disk-82.vhdx).DiskNumber"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Initialize-Disk -Number 14 -PartitionStyle GPT"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-Partition -DiskNumber 14 -UseMaximumSize"
    volume_test.go:253: Checking that the size is inside the bounds: 1052770304 < (actual) 1056894976 < 1073741824
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Dismount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\disk-82.vhdx"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rm C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\disk-82.vhdx"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\mount-66"
    volume_test.go:25: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-5.csi.io\\"
--- PASS: TestVolumeAPIs (104.49s)
    --- PASS: TestVolumeAPIs/E2E (57.27s)
    --- PASS: TestVolumeAPIs/NegativeDiskTests (0.00s)
    --- PASS: TestVolumeAPIs/NegativeVolumeTests (10.31s)
    --- PASS: TestVolumeAPIs/VolumeAPICompatibilityTests (36.91s)
PASS
ok      github.com/kubernetes-csi/csi-proxy/integrationtests    104.828s

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 24, 2021
@mauriciopoppe
Copy link
Member Author

@jingxu97 @ddebroy I've added tests for v1alpha1, v1beta1 and v1beta2, the output is:

PS C:\Users\mauriciopoppe\go\src\github.com\kubernetes-csi\csi-proxy> go test -v .\integrationtests\ -run TestVolumeAPIs

=== RUN   TestVolumeAPIs
=== RUN   TestVolumeAPIs/NegativeDiskTests
=== RUN   TestVolumeAPIs/NegativeVolumeTests
=== RUN   TestVolumeAPIs/v1alpha1Tests
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c mkdir C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\mount-6"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\disk-60.vhdx -SizeBytes 1073741824"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Mount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\disk-60.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c (Get-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\disk-60.vhdx).DiskNumber"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Initialize-Disk
-Number 17 -PartitionStyle GPT"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-Partition -D
iskNumber 17 -UseMaximumSize"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Resize-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\disk-60.vhdx -SizeBytes 2147483648"
    volume_v1alpha1_test.go:78: Attempt to resize volume from sizeBytes=1073741824 to sizeBytes=1610612736
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Dismount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\disk-60.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rm C:\\var\\lib\\kubelet\\plugins\\testplugin-68.csi.io\\disk-60.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\l
ib\\kubelet\\plugins\\testplugin-68.csi.io\\mount-6"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\l
ib\\kubelet\\plugins\\testplugin-68.csi.io\\"
=== RUN   TestVolumeAPIs/v1beta1Tests
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c mkdir C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\mount-52"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\disk-46.vhdx -SizeBytes 1073741824"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Mount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\disk-46.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c (Get-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\disk-46.vhdx).DiskNumber"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Initialize-Disk -Number 17 -PartitionStyle GPT"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-Partition -D
iskNumber 17 -UseMaximumSize"
    volume_test.go:129: Checking that the size is inside the bounds: 1052770304 < (actual) 1056894976 < 1073741824
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Resize-VHD -Path
 C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\disk-46.vhdx -SizeBytes 2147483648"
    volume_v1beta1_test.go:100: Attempt to resize volume from sizeBytes=1056894976 to sizeBytes=1585342464
    volume_test.go:129: Checking that the size is inside the bounds: 1564370944 < (actual) 1585340416 < 1585342464
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Dismount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\disk-46.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rm C:\\var\\lib\\kubelet\\plugins\\testplugin-18.csi.io\\disk-46.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\l
ib\\kubelet\\plugins\\testplugin-18.csi.io\\mount-52"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\l
ib\\kubelet\\plugins\\testplugin-18.csi.io\\"
=== RUN   TestVolumeAPIs/v1beta2Tests
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c mkdir C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\mount-70"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\disk-76.vhdx -SizeBytes 1073741824"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Mount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\disk-76.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c (Get-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\disk-76.vhdx).DiskNumber"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Initialize-Disk -Number 17 -PartitionStyle GPT"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-Partition -DiskNumber 17 -UseMaximumSize"
    volume_test.go:129: Checking that the size is inside the bounds: 1052770304 < (actual) 1056894976 < 1073741824
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Resize-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\disk-76.vhdx -SizeBytes 2147483648"
    volume_v1beta2_test.go:99: Attempt to resize volume from sizeBytes=1056894976 to sizeBytes=1585342464
    volume_test.go:129: Checking that the size is inside the bounds: 1564370944 < (actual) 1585340416 < 1585342464
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Dismount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\disk-76.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rm C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\disk-76.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\mount-70"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-63.csi.io\\"
=== RUN   TestVolumeAPIs/v1beta3Tests
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c mkdir C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\mount-65"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\disk-49.vhdx -SizeBytes 1073741824"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Mount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\disk-49.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c (Get-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\disk-49.vhdx).DiskNumber"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Initialize-Disk -Number 17 -PartitionStyle GPT"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c New-Partition -DiskNumber 17 -UseMaximumSize"
    volume_v1beta3_test.go:73: VolumeId \\?\Volume{5e5fba17-9a3c-4102-8abd-6048e294ca69}\
    volume_test.go:129: Checking that the size is inside the bounds: 1052770304 < (actual) 1056894976 < 1073741824
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Resize-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\disk-49.vhdx -SizeBytes 2147483648"
    volume_v1beta3_test.go:112: Attempt to resize volume from sizeBytes=1056894976 to sizeBytes=1585342464
    volume_test.go:129: Checking that the size is inside the bounds: 1564370944 < (actual) 1585340416 < 1585342464
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c Dismount-VHD -Path C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\disk-49.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rm C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\disk-49.vhdx"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\mount-65"
    utils.go:164: Executing command: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c rmdir C:\\var\\lib\\kubelet\\plugins\\testplugin-16.csi.io\\"
--- PASS: TestVolumeAPIs (206.18s)
    --- PASS: TestVolumeAPIs/NegativeDiskTests (0.00s)
    --- PASS: TestVolumeAPIs/NegativeVolumeTests (10.23s)
    --- PASS: TestVolumeAPIs/v1alpha1Tests (42.16s)
    --- PASS: TestVolumeAPIs/v1beta1Tests (49.65s)
    --- PASS: TestVolumeAPIs/v1beta2Tests (50.24s)
    --- PASS: TestVolumeAPIs/v1beta3Tests (53.90s)
PASS
ok      github.com/kubernetes-csi/csi-proxy/integrationtests    206.540s

}
// For a volume formatted with 1GB it should be around 1GB, in practice it was 1056947712 bytes or 0.9844GB
// let's compare with a range of - 20MB
if !sizeIsAround(t, volumeStatsResponse.VolumeSize, vhd.InitialSize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how it was handled before your change?

Copy link
Member Author

Choose a reason for hiding this comment

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

this wasn't tested before, I added this part

// (considers the fact that some bytes were lost)
func sizeIsAround(t *testing.T, actualSize, expectedSize int64) bool {
// An upper bound on the number of bytes that are lost when creating or resizing a partition
var volumeSizeBytesLoss int64 = (20 * 1024 * 1024)
Copy link
Contributor

Choose a reason for hiding this comment

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

how this volumeSizeBytesLoss is obtained? Is there some doc related to this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I got this value from looking at the GetStats output after you format a partition, if you format it to 1GB you'r getting actually ~0.9844GB, probably @ddebroy might help us understanding where are those bytes going :)

Anyways if you do 1GB - 20MB that's around 0.98GB which I thought it was a good lower bound

@jingxu97
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2021
@k8s-ci-robot k8s-ci-robot merged commit 22e16c3 into kubernetes-csi:master May 31, 2021
@@ -177,36 +213,36 @@ func (VolAPIImplementor) VolumeStats(volumeID string) (int64, int64, error) {
volumeSizeRemaining = getVolume["SizeRemaining"]

volumeUsedSize := volumeSize - volumeSizeRemaining
return volumeSizeRemaining, volumeUsedSize, nil
return volumeSize, volumeUsedSize, nil
Copy link
Member Author

Choose a reason for hiding this comment

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

This issue was raised during one of our meetings:

	totalBytes, usedBytes, err := s.hostAPI.GetVolumeStats(volumeID)

	volumeSize = getVolume["Size"]
	volumeSizeRemaining = getVolume["SizeRemaining"]
	volumeUsedSize := volumeSize - volumeSizeRemaining
	return volumeSizeRemaining, volumeUsedSize, nil

      // proposed
	return volumeSize, volumeUsedSize, nil

Have we ever attempted to do a resize? I tried running a resize from 1GB to 2GB and I get:

PS C:\Users\mauriciopoppe\go\src\github.com\kubernetes-csi\csi-proxy> Get-Volume -UniqueId "\\?\Volume{1b6810f3-20a3-4a2f-bd7b-3b36f05265d4}\" | Get-partition


   DiskPath: \\?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000006#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
2                            16777216                                1007.94 MB Basic


PS C:\Users\mauriciopoppe\go\src\github.com\kubernetes-csi\csi-proxy> Get-Volume -UniqueId "\\?\Volume{1b6810f3-20a3-4a2f-bd7b-3b36f05265d4}\" | Get-partition | Resize-Partition -Size 2147483648
Resize-Partition : Not enough available capacity
Activity ID: {229be40a-070d-41ff-b027-d71015bacf61}
At line:1 char:92
+ ... b-3b36f05265d4}\" | Get-partition | Resize-Partition -Size 2147483648
+                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (StorageWMI:ROOT/Microsoft/.../MSFT_Partition) [Resize-Partition], CimException
    + FullyQualified

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/feature Categorizes issue or PR as related to a new feature. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updates in the Volume v1beta3 API
4 participants