Skip to content

fix(collector): skip unidentified devices, add exclude list and bounded parallel collection - #969

Merged
Starosdev merged 4 commits into
betafrom
fix/965-collector-robustness
Oct 13, 2026
Merged

Starosdev merged 4 commits into
betafrom
fix/965-collector-robustness

Conversation

@Starosdev

@Starosdev Starosdev commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

WP-D (collector robustness) for the 2.0.0 release. The collector stops registering devices it could not identify, gains an exclude: list plus a built-in virtual-disk exclusion, and can collect SMART data from several devices in parallel (default unchanged: one at a time).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or infrastructure change

Related Issues

Related to #965. Addresses #913 and #912.

Changes Made

  • Detection (Linux, darwin, windows, freebsd) does not register a device when smartctl --info fails: fatal exit status, non-exit errors such as timeout or missing binary, empty output, or undecodable JSON. Non-fatal exit bits (for example exit 4, fix(collector): preserve jmb39x-q device type and accept usable SMART JSON #663) still register. Previously these devices registered without identity and were a likely source of duplicate devices. Each skipped device is reported every run as a collector scan error (ReportScanError("info", ...)), which notifies through notify_on_collector_error like before, so a hard-failing drive still alerts.
  • New exclude: list of regexes matched against device path, model name, and device type; invalid patterns are skipped with a WARN. Checked before --info (path, type) and after it (model).
  • New exclude_virtual_disks (default true): skips QEMU HARDDISK, VBOX HARDDISK, and Virtual Disk / Msft Virtual Disk models, case-insensitive, with one INFO line. Devices listed explicitly under devices: or in allow_listed_devices are never skipped by the built-in list; user exclude: patterns still apply. Patterns compile once per scan.
  • New commands.metrics_parallelism (default 1, today's behavior; values below 1 are treated as 1). metrics_smartctl_wait now applies per worker.
  • Fixed a data race in config.GetDeviceOverrides() memoization found by -race.
  • Documented in example.collector.yaml and docs/TROUBLESHOOTING_DEVICE_COLLECTOR.md.

Testing

  • I have tested this locally
  • I have added/updated tests that prove my fix/feature works
  • All existing tests pass

go build ./..., go vet ./..., go test -race ./collector/..., go test ./..., GOOS=windows|freebsd|darwin go vet ./collector/... clean, GOOS=linux golangci-lint run --new-from-rev=origin/beta ./... (v2.14.0) 0 issues. New tests cover fatal, timeout, empty, and bad-JSON --info (unregistered, recorded, one scan error each) versus exit-4, virtual-disk exclusion on and off, user patterns including an invalid regex, type exclusion, and explicit devices exempt from built-ins, and parallelism 1/3/0 with a channel barrier for peak concurrency.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code where necessary (particularly complex areas)
  • I have updated the documentation if needed
  • My changes generate no new warnings

Notes

  • Breaking (footer on 0a452cd): devices that fail identification are reported as scan errors instead of registered, and virtual-disk models are skipped by default unless listed explicitly or exclude_virtual_disks: false. Previously registered devices in either group stop updating; they are not archived.
  • Difference from 1.x: an unidentified device's failure is a scan-level error, so its existing dashboard row is not marked with a collector error.
  • The virtual-disk model strings come from [FEAT] Detect virtual disks and skip or mark them unsupported instead of failed #912; not verified against real smartctl output.
  • exclude must be a YAML list; the COLLECTOR_EXCLUDE env var splits on whitespace.
  • With metrics_parallelism above 1, collector config is read from several goroutines; avoid Set() on it after startup.
  • Pre-existing and unrelated: collector/pkg/mdadm/detect/mount_linux.go:98 fails GOOS=linux go vet from arm64 hosts.

Review: not required (collector change on the beta integration branch; no production effect until a release, but an independent read-only review is being run per release coordination)

…ded parallel collection

- Skip registration of devices whose smartctl --info call failed (fatal exit
  status, no output, undecodable output) on linux, darwin, windows and
  freebsd. Non-fatal exit bits (for example 4, #663) still register.
- Add an exclude list of regular expressions matched against device path,
  model name and device type, plus a default-on exclusion of emulated disks
  (QEMU HARDDISK, VBOX HARDDISK, Virtual Disk, Msft Virtual Disk) that is
  disabled with exclude_virtual_disks: false. Excluded devices log once at
  INFO and are not reported as failed.
- Add commands.metrics_parallelism (default 1) to collect SMART data for
  several devices at once, and guard the memoized device overrides in the
  collector config against concurrent reads.
@Starosdev Starosdev added collector Collector component go Pull requests that update go code labels Oct 13, 2026
…t explicit devices

Devices left out of registration because smartctl --info failed are recorded
in Detect.Skipped and sent as an info scan error on every run, so a failing
drive still raises a collector error. Exclude patterns are compiled once per
scan. The built-in virtual disk patterns no longer apply to devices named in
the devices section or allow_listed_devices. Parallelism tests use a barrier
instead of sleeps.
…er wait

BREAKING CHANGE: devices whose smartctl --info call fails are no longer
registered; the failure is reported as a collector scan error instead. Disks
whose model is QEMU HARDDISK, VBOX HARDDISK, Virtual Disk or Msft Virtual Disk
are skipped by default unless listed explicitly under devices or
allow_listed_devices, or exclude_virtual_disks is set to false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

collector Collector component go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant