-
Notifications
You must be signed in to change notification settings - Fork 31
Tink Agent: filter out block devices with unknown controller type #321
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
Tink Agent: filter out block devices with unknown controller type #321
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
==========================================
- Coverage 50.82% 50.80% -0.03%
==========================================
Files 105 105
Lines 8807 8807
==========================================
- Hits 4476 4474 -2
- Misses 4068 4070 +2
Partials 263 263 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| for _, d := range b.Disks { | ||
| if d == nil { | ||
| // XXX: inside a VM, we see /dev/ramXX and the underlying library seems to think its a BlockDevice | ||
| if d == nil || d.Vendor == "unknown" { |
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.
Hey @kmullin, thanks for this. We'll need a different approach here though. With this logic, the following devices would be excluded.
This is from a physical machine I have:
{
"name": "nvme0n1",
"controllerType": "NVMe",
"driveType": "SSD",
"size": "239GB",
"physicalBlockSize": "512B",
"vendor": "unknown",
"model": "KINGSTON OM8PDP3256B-A01"
}This is from a qemu VM I regularly use to test:
{
"controllerType": "NVMe",
"driveType": "SSD",
"model": "unknown",
"name": "nvme0n1",
"physicalBlockSize": "512B",
"size": "10GB",
"vendor": "unknown"
},Maybe one of the following options could be used.
if d == nil || strings.HasPrefix(d.Name, "nbd") || strings.HasPrefix(d.Name, "ram") {
continue
}OR
if d.StorageController != block.STORAGE_CONTROLLER_LOOP && d.StorageController != block.STORAGE_CONTROLLER_UNKNOWN {
...
}I'm leaning toward the second one. What are your thoughts?
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.
Here are 2 more entries from a Raspberry PI 5. The SD card and the NVMe drive show an unknown vendor.
{
"controllerType": "MMC",
"driveType": "SSD",
"model": "unknown",
"name": "mmcblk0",
"physicalBlockSize": "512B",
"size": "29GB",
"vendor": "unknown"
}{
"controllerType": "NVMe",
"driveType": "SSD",
"model": "unknown",
"name": "nvme0n1",
"physicalBlockSize": "512B",
"size": "233GB",
"vendor": "unknown"
}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.
You're amazing! Thanks for double checking this. Yes I suppose my solution is not great.
I'll take a closer look at what you've proposed with the second option and test out on some other hardware too!
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.
yeah I see that the controller type is basically set from device prefixes already: https://github.com/jaypipes/ghw/blob/e75a40d23a6cb2e7314ccedd4a20a2e92542332f/pkg/block/block_linux.go#L382-L420
So that is likely better than doing another prefix filtering.
I've also updated the references to use the non-deprecated versions of the same thing.
This appears to work in my testing environment the same way.
85f12cc to
7cc8b6c
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.
Thanks again for this!
|
This pull request has been removed from the queue for the following reason: Pull request #321 has been dequeued. The pull request could not be merged. This could be related to an activated branch protection or ruleset rule that prevents us from merging. (details: Repository rule violations found Commits must have verified signatures. ). You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. |
Hey @kmullin, apologies. Would you mind setting up the GitHub verified signatures? |
while testing inside VMs, the auto-discovery feature of the tink-agent
discovers disks /dev/ram{1..15} and /dev/nbd{0..15}. This change
filters those out and prefers block devices which have a controllerType
which isnt Loop or Unknown
Signed-off-by: Kevin Mullin <[email protected]>
7cc8b6c to
568d934
Compare
|
Sure thing! I force pushed a signed commit. Sorry for the troubles. |
No worries at all, thanks for doing it! |
…nkerbell#321) ## Description while testing inside VMs, the auto-discovery feature of the tink-agent discovers disks /dev/ram{1..15} and /dev/nbd{0..15}. This change filters those out and prefers block devices which have a controllerType which isnt Loop or Unknown This was found on HookOS 0.10.0-build-196. ## Why is this needed I'm unsure if *all* block devices are going to be discovered Fixes: # ## How Has This Been Tested? At least in my lab, on VMs and limited hardware types, this still correctly detects block devices which have an actual vendor reported from the device, and does not add every single "block" device to `spec.disks` in the generated `Hardware` object. ~The underlying `ghw` package reads from `/sys/block/<dev>/device/vendor`, and if the file doesn't exist will default to `"unknown"`~ [seen here](https://github.com/jaypipes/ghw/blob/v0.17.0/pkg/block/block_linux.go#L82-L91). I am fairly confident this is safe, but due to limited hardware availability, I'd love to get some feedback. ## How are existing users impacted? What migration steps/scripts do we need? ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
…nkerbell#321) ## Description while testing inside VMs, the auto-discovery feature of the tink-agent discovers disks /dev/ram{1..15} and /dev/nbd{0..15}. This change filters those out and prefers block devices which have a controllerType which isnt Loop or Unknown This was found on HookOS 0.10.0-build-196. ## Why is this needed I'm unsure if *all* block devices are going to be discovered Fixes: # ## How Has This Been Tested? At least in my lab, on VMs and limited hardware types, this still correctly detects block devices which have an actual vendor reported from the device, and does not add every single "block" device to `spec.disks` in the generated `Hardware` object. ~The underlying `ghw` package reads from `/sys/block/<dev>/device/vendor`, and if the file doesn't exist will default to `"unknown"`~ [seen here](https://github.com/jaypipes/ghw/blob/v0.17.0/pkg/block/block_linux.go#L82-L91). I am fairly confident this is safe, but due to limited hardware availability, I'd love to get some feedback. ## How are existing users impacted? What migration steps/scripts do we need? ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
…nkerbell#321) ## Description while testing inside VMs, the auto-discovery feature of the tink-agent discovers disks /dev/ram{1..15} and /dev/nbd{0..15}. This change filters those out and prefers block devices which have a controllerType which isnt Loop or Unknown This was found on HookOS 0.10.0-build-196. ## Why is this needed I'm unsure if *all* block devices are going to be discovered Fixes: # ## How Has This Been Tested? At least in my lab, on VMs and limited hardware types, this still correctly detects block devices which have an actual vendor reported from the device, and does not add every single "block" device to `spec.disks` in the generated `Hardware` object. ~The underlying `ghw` package reads from `/sys/block/<dev>/device/vendor`, and if the file doesn't exist will default to `"unknown"`~ [seen here](https://github.com/jaypipes/ghw/blob/v0.17.0/pkg/block/block_linux.go#L82-L91). I am fairly confident this is safe, but due to limited hardware availability, I'd love to get some feedback. ## How are existing users impacted? What migration steps/scripts do we need? ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
Description
while testing inside VMs, the auto-discovery feature of the tink-agent discovers disks /dev/ram{1..15} and /dev/nbd{0..15}. This change filters those out and prefers block devices which have a controllerType which isnt Loop or Unknown
This was found on HookOS 0.10.0-build-196.
Why is this needed
I'm unsure if all block devices are going to be discovered
Fixes: #
How Has This Been Tested?
At least in my lab, on VMs and limited hardware types, this still correctly detects block devices which have an actual vendor reported from the device, and does not add every single "block" device to
spec.disksin the generatedHardwareobject.The underlyingseen here.ghwpackage reads from/sys/block/<dev>/device/vendor, and if the file doesn't exist will default to"unknown"I am fairly confident this is safe, but due to limited hardware availability, I'd love to get some feedback.
How are existing users impacted? What migration steps/scripts do we need?
Checklist:
I have: