-
Notifications
You must be signed in to change notification settings - Fork 61
Use WMI to implement Volume API to reduce PowerShell overhead #360
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
Conversation
Welcome @laozc! |
Hi @laozc. Thanks for your PR. I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
thanks for the PR. @laozc have you tested the WMI based operation manually? does it work? |
Yes. I verified it in my local environment and they work the same as PowerShell commands. |
/cc @andyzhangx @mauriciopoppe |
7ee9449
to
c55b906
Compare
@laozc I tries to copy the cim folder into my Azure Disk CSI driver repo (for test): https://github.com/kubernetes-sigs/azuredisk-csi-driver/compare/master...andyzhangx:azuredisk-csi-driver:cim?expand=1, but I got following error, have you hit similar error in your CSI driver? https://github.com/andyzhangx/azuredisk-csi-driver/actions/runs/14463170910/job/40559504163
|
Hi, these Go files in You may either
to each file in this package so the test coverage is skipped for these files on Linux. |
I could add build constraints to these codes if the downstream projects need.
|
yes, that's necessary, and pls also add header, you could refer to |
ca57b91
to
dd7bed2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
I am trying the new cim calls
@laozc do you have the link about how this WMI improves the performance? pls paste details in this PR description, thanks. |
I updated the PR description to include my benchmark result mentioned in #360 (comment) |
@andyzhangx Good to see the change works well on azuredisk-csi-driver. |
@laozc do you have any debug tips about how to call WMI on Windows node? we use powershell command on windows node, that's quite easier in debugging issues. |
@andyzhangx You can still use PowerShell, with a different cmdlet to query from CIM. PS > (Get-CimInstance -Namespace "Root\Microsoft\Windows\Storage" -Query "SELECT * FROM MSFT_Volume")[0]
ObjectId : {1}\\WIN-8E2EVAQ9QSB\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId=
"{b65bb3cd-da86-11ee-854b-806e6f6e6963}:VO:\\?\Volume{1781d1eb-2c0a-47ed-987f-c229b9c
02527}\"
PassThroughClass :
PassThroughIds :
PassThroughNamespace :
PassThroughServer :
UniqueId : \\?\Volume{1781d1eb-2c0a-47ed-987f-c229b9c02527}\
AllocationUnitSize : 4096
DedupMode : 4
DriveLetter : C
DriveType : 3
FileSystem : NTFS
FileSystemLabel :
FileSystemType : 14
HealthStatus : 1
OperationalStatus : {53261}
Path : \\?\Volume{1781d1eb-2c0a-47ed-987f-c229b9c02527}\
Size : 536198770688
SizeRemaining : 407553982464
PSComputerName : The query is the same as what this PR calls in the implementation of If you need to call static method, you may do this like this. PS > $class = Get-CimClass -ClassName MSFT_iSCSITarget -Namespace "Root\Microsoft\Windows\Storage"
PS > Invoke-CimMethod -CimClass $class -MethodName "Connect" @{NodeAddress="iqn.1998-01.com.vmware:52eb662431c68fa9-2792e31529536a3a";AuthenticationType="MUTUALCHAP";ChapSecret="--";ChapUsername="zhongchengl";} You could find the corresponding WMI query and invocation except for the case with some direct Win32 API calls in this PR. I believe the non-WMI approach works as a human admin/user or integration test cases. For a Go-based program CSI-proxy running on Windows nodes, it makes less sense to use PowerShell to automate these tasks, especially considering the overhead which .NET may bring. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold cancel
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, laozc 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 |
/kind feature
What this PR does / why we need it:
This PR leverages of WMI interfaces to replace the PowerShell functions for Windows related storage operations,
which improve the overall performance of csi-proxy.
Ran some test with two Windows nodes setup, one with the CSI-proxy with PowerShell, while another one with the CSI-proxy using WMI.
The test creates two pods side by side and delete the resources from the cluster once they're running.
Here is the performance data with collected from the gRPC server metrics within 10 minutes time frame.
It's obviously shown that PowerShell takes around 2.9s to load in the environment while memory consumption could reach up to 200MB, which becomes the bottle neck for volume mount on Windows.
By reducing the PowerShell overhead, we were able to cut down the time cost significantly to method calls for all operations.
Which issue(s) this PR fixes:
Ref #193
Special notes for your reviewer:
Does this PR introduce a user-facing change?: