Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kmullin
Copy link
Contributor

@kmullin kmullin commented Aug 12, 2025

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.

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

@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 50.80%. Comparing base (c26c3ab) to head (568d934).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
tink/agent/internal/attribute/attribute.go 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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" {
Copy link
Member

@jacobweinstock jacobweinstock Aug 13, 2025

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?

Copy link
Member

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"
}

Copy link
Contributor Author

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!

Copy link
Contributor Author

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.

@kmullin kmullin force-pushed the kmullin/block-device-filtering branch from 85f12cc to 7cc8b6c Compare August 15, 2025 04:11
@kmullin kmullin changed the title Tink Agent: filter out block devices with unknown vendor Tink Agent: filter out block devices with unknown controller type Aug 15, 2025
Copy link
Member

@jacobweinstock jacobweinstock left a 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!

@jacobweinstock jacobweinstock added the ready-to-merge Signal Mergify to merge the PR label Aug 15, 2025
@mergify
Copy link
Contributor

mergify bot commented Aug 15, 2025

This pull request has been removed from the queue for the following reason: pull request dequeued.

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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@jacobweinstock
Copy link
Member

This pull request has been removed from the queue for the following reason: pull request dequeued.

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. If you do update this pull request, it will automatically be requeued once the queue conditions match again. If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

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]>
@kmullin kmullin force-pushed the kmullin/block-device-filtering branch from 7cc8b6c to 568d934 Compare August 15, 2025 16:35
@kmullin
Copy link
Contributor Author

kmullin commented Aug 15, 2025

Sure thing! I force pushed a signed commit. Sorry for the troubles.

@jacobweinstock
Copy link
Member

Sure thing! I force pushed a signed commit. Sorry for the troubles.

No worries at all, thanks for doing it!

@mergify mergify bot merged commit c7ede0c into tinkerbell:main Aug 15, 2025
11 checks passed
@kmullin kmullin deleted the kmullin/block-device-filtering branch August 15, 2025 21:03
elauriault pushed a commit to elauriault/tinkerbell that referenced this pull request Oct 17, 2025
…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
elauriault pushed a commit to elauriault/tinkerbell that referenced this pull request Oct 18, 2025
…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
elauriault pushed a commit to elauriault/tinkerbell that referenced this pull request Oct 18, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Signal Mergify to merge the PR tink-agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants