-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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: Filtering out ramdisks in diskio metricset #12829
Conversation
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.
Tested locally on Windows 10 Home
@@ -224,5 +228,36 @@ func isValidLogicalDrive(path string) bool { | |||
if ret == 1 || ret == 5 || err != errorSuccess { |
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.
The code filters volumes by disk type at the moment but ramdisk will show up as a fixed disk and will not be filtered out.
So, GetDriveTypeW
returns 3 (DRIVE_FIXED
) for ram disks? In theory it can also return 6 (DRIVE_RAMDISK
) 🤔
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.
@jsoriano, I do see there is a separate type for it, 6 (https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdrivetypew) based on the api call but it will return type 3, even when retrieving the drive type using the cmd line (ex. wmic logicaldisk get caption,description,drivetype,providername,volumename).
I can add the type 6 in the condition but it will not help in this specific case.
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.
No need to add it if checking the volume label is more reliable. Thanks for the explanation.
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.
added it either way, along with unknown type
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 😬 Are you planning to add some unit tests?
Should fix #12814
The code filters volumes by disk type at the moment but ramdisk will show up as a fixed disk and will not be filtered out. The performance counter function (DeviceIoControl) will fail in this case.
ramdisk
volume label