Skip to content

fix: prevent panic when using diskstats device-include only (#3590)#3603

Merged
SuperQ merged 1 commit intoprometheus:masterfrom
mumberrymountain:fix-issue-3590-diskstats-device-include-only-panic
Apr 3, 2026
Merged

fix: prevent panic when using diskstats device-include only (#3590)#3603
SuperQ merged 1 commit intoprometheus:masterfrom
mumberrymountain:fix-issue-3590-diskstats-device-include-only-panic

Conversation

@mumberrymountain
Copy link
Copy Markdown
Contributor

this PR fix issue #3590.

Problem:
setting --collector.diskstats.device-include alone trigger the “device-exclude & device-include are mutually exclusive” error and ultimately cause panic during handler creation.

Cause:

diskstatsDeviceExclude    = kingpin.Flag(
		"collector.diskstats.device-exclude",
		"Regexp of diskstats devices to exclude (mutually exclusive to device-include).",
	).Default(diskstatsDefaultIgnoredDevices).PreAction(func(c *kingpin.ParseContext) error {
		diskstatsDeviceExcludeSet = true
		return nil
}).String()

collector.diskstats.device-exclude has a non-empty default on Linux,

if *diskstatsDeviceExclude != "" && *diskstatsDeviceInclude != "" {
		return deviceFilter{}, errors.New("device-exclude & device-include are mutually exclusive")
}

as a result, providing device-include only still leaves device-exclude as default, so the code treats it as include+exclude all being set and throws error.

Fix

if *diskstatsDeviceInclude != "" {
	if diskstatsDeviceExcludeSet {
		return deviceFilter{}, errors.New("device-exclude & device-include are mutually exclusive")
	}
	*diskstatsDeviceExclude = ""
}

When device-include is set:

  • Return a mutual exclusivity error only if device-exclude was explicitly provided by the user
  • Otherwise, ignore/clear the default exclude so include-only works as intended

…us#3590)

Signed-off-by: Jeon Insoo <mumberrymountain@gmail.com>
@mumberrymountain mumberrymountain force-pushed the fix-issue-3590-diskstats-device-include-only-panic branch from 15bceac to 110272f Compare April 2, 2026 11:55
Copy link
Copy Markdown
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@SuperQ SuperQ merged commit aaf76b5 into prometheus:master Apr 3, 2026
13 checks passed
SuperQ added a commit that referenced this pull request Apr 4, 2026
* [CHANGE] Adds distroless container image. #3592
* [FEATURE] infiniband: Add `hw_counters` metrics #2827
* [FEATURE] kernel_hung: Add collector for kernel hung tasks #3470
* [FEATURE] mixin: Add "All" option to cluster variable in dashboards #3509
* [FEATURE] netlink: Add node_network_altnames_info metric #3541
* [FEATURE] thermal: Add support for CPU temperature metrics on Apple Silicon #3547
* [FEATURE] bcachefs: Add new collector for bcachefs #3523
* [ENHANCEMENT] mixin: Make devices in network graphs configurable #3525
* [ENHANCEMENT] nvme: Add namespace parameters #3360
* [BUGFIX] netdev: Respect deviceFilter for `node_network_address_info` metric #3340
* [BUGFIX] mountstats: Fix multiple transports statistics labeling #3358
* [BUGFIX] diskstats: Fix panic when using device-include flag only #3603

Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ SuperQ mentioned this pull request Apr 4, 2026
SuperQ added a commit that referenced this pull request Apr 4, 2026
* [CHANGE] Adds distroless container image. #3592
* [FEATURE] infiniband: Add `hw_counters` metrics #2827
* [FEATURE] kernel_hung: Add collector for kernel hung tasks #3470
* [FEATURE] mixin: Add "All" option to cluster variable in dashboards #3509
* [FEATURE] netlink: Add node_network_altnames_info metric #3541
* [FEATURE] thermal: Add support for CPU temperature metrics on Apple Silicon #3547
* [FEATURE] bcachefs: Add new collector for bcachefs #3523
* [ENHANCEMENT] mixin: Make devices in network graphs configurable #3525
* [ENHANCEMENT] nvme: Add namespace parameters #3360
* [BUGFIX] netdev: Respect deviceFilter for `node_network_address_info` metric #3340
* [BUGFIX] mountstats: Fix multiple transports statistics labeling #3358
* [BUGFIX] diskstats: Fix panic when using device-include flag only #3603

Signed-off-by: Ben Kochie <superq@gmail.com>
SuperQ added a commit that referenced this pull request Apr 4, 2026
* [CHANGE] Adds distroless container image. #3592
* [FEATURE] infiniband: Add `hw_counters` metrics #2827
* [FEATURE] kernel_hung: Add collector for kernel hung tasks #3470
* [FEATURE] mixin: Add "All" option to cluster variable in dashboards #3509
* [FEATURE] netlink: Add node_network_altnames_info metric #3541
* [FEATURE] thermal: Add support for CPU temperature metrics on Apple Silicon #3547
* [FEATURE] bcachefs: Add new collector for bcachefs #3523
* [ENHANCEMENT] mixin: Make devices in network graphs configurable #3525
* [ENHANCEMENT] nvme: Add namespace parameters #3360
* [BUGFIX] netdev: Respect deviceFilter for `node_network_address_info` metric #3340
* [BUGFIX] mountstats: Fix multiple transports statistics labeling #3358
* [BUGFIX] diskstats: Fix panic when using device-include flag only #3603

Signed-off-by: Ben Kochie <superq@gmail.com>
renovate bot added a commit to sdwilsh/sOS that referenced this pull request Apr 7, 2026
….11.1

##### [\`v1.11.1\`](https://github.com/prometheus/node_exporter/releases/tag/v1.11.1)

- \[BUGFIX] Fix kernel\_hung for no data [#3613](prometheus/node_exporter#3613)

---
##### [\`v1.11.0\`](https://github.com/prometheus/node_exporter/releases/tag/v1.11.0)

- \[CHANGE] Adds distroless container image. [#3592](prometheus/node_exporter#3592)
- \[FEATURE] infiniband: Add `hw_counters` metrics [#2827](prometheus/node_exporter#2827)
- \[FEATURE] kernel\_hung: Add collector for kernel hung tasks [#3470](prometheus/node_exporter#3470)
- \[FEATURE] mixin: Add "All" option to cluster variable in dashboards [#3509](prometheus/node_exporter#3509)
- \[FEATURE] netlink: Add node\_network\_altnames\_info metric [#3541](prometheus/node_exporter#3541)
- \[FEATURE] thermal: Add support for CPU temperature metrics on Apple Silicon [#3547](prometheus/node_exporter#3547)
- \[FEATURE] bcachefs: Add new collector for bcachefs [#3523](prometheus/node_exporter#3523)
- \[ENHANCEMENT] mixin: Make devices in network graphs configurable [#3525](prometheus/node_exporter#3525)
- \[ENHANCEMENT] nvme: Add namespace parameters [#3360](prometheus/node_exporter#3360)
- \[BUGFIX] netdev: Respect deviceFilter for `node_network_address_info` metric [#3340](prometheus/node_exporter#3340)
- \[BUGFIX] mountstats: Fix multiple transports statistics labeling [#3358](prometheus/node_exporter#3358)
- \[BUGFIX] diskstats: Fix panic when using device-include flag only [#3603](prometheus/node_exporter#3603)
renovate bot added a commit to sdwilsh/ansible-playbooks that referenced this pull request Apr 8, 2026
….11.1

##### [\`v1.11.1\`](https://github.com/prometheus/node_exporter/releases/tag/v1.11.1)

- \[BUGFIX] Fix kernel\_hung for no data [#3613](prometheus/node_exporter#3613)

---
##### [\`v1.11.0\`](https://github.com/prometheus/node_exporter/releases/tag/v1.11.0)

- \[CHANGE] Adds distroless container image. [#3592](prometheus/node_exporter#3592)
- \[FEATURE] infiniband: Add `hw_counters` metrics [#2827](prometheus/node_exporter#2827)
- \[FEATURE] kernel\_hung: Add collector for kernel hung tasks [#3470](prometheus/node_exporter#3470)
- \[FEATURE] mixin: Add "All" option to cluster variable in dashboards [#3509](prometheus/node_exporter#3509)
- \[FEATURE] netlink: Add node\_network\_altnames\_info metric [#3541](prometheus/node_exporter#3541)
- \[FEATURE] thermal: Add support for CPU temperature metrics on Apple Silicon [#3547](prometheus/node_exporter#3547)
- \[FEATURE] bcachefs: Add new collector for bcachefs [#3523](prometheus/node_exporter#3523)
- \[ENHANCEMENT] mixin: Make devices in network graphs configurable [#3525](prometheus/node_exporter#3525)
- \[ENHANCEMENT] nvme: Add namespace parameters [#3360](prometheus/node_exporter#3360)
- \[BUGFIX] netdev: Respect deviceFilter for `node_network_address_info` metric [#3340](prometheus/node_exporter#3340)
- \[BUGFIX] mountstats: Fix multiple transports statistics labeling [#3358](prometheus/node_exporter#3358)
- \[BUGFIX] diskstats: Fix panic when using device-include flag only [#3603](prometheus/node_exporter#3603)
sdwilsh pushed a commit to sdwilsh/ansible-playbooks that referenced this pull request Apr 8, 2026
….11.1

##### [\`v1.11.1\`](https://github.com/prometheus/node_exporter/releases/tag/v1.11.1)

- \[BUGFIX] Fix kernel\_hung for no data [#3613](prometheus/node_exporter#3613)

---
##### [\`v1.11.0\`](https://github.com/prometheus/node_exporter/releases/tag/v1.11.0)

- \[CHANGE] Adds distroless container image. [#3592](prometheus/node_exporter#3592)
- \[FEATURE] infiniband: Add `hw_counters` metrics [#2827](prometheus/node_exporter#2827)
- \[FEATURE] kernel\_hung: Add collector for kernel hung tasks [#3470](prometheus/node_exporter#3470)
- \[FEATURE] mixin: Add "All" option to cluster variable in dashboards [#3509](prometheus/node_exporter#3509)
- \[FEATURE] netlink: Add node\_network\_altnames\_info metric [#3541](prometheus/node_exporter#3541)
- \[FEATURE] thermal: Add support for CPU temperature metrics on Apple Silicon [#3547](prometheus/node_exporter#3547)
- \[FEATURE] bcachefs: Add new collector for bcachefs [#3523](prometheus/node_exporter#3523)
- \[ENHANCEMENT] mixin: Make devices in network graphs configurable [#3525](prometheus/node_exporter#3525)
- \[ENHANCEMENT] nvme: Add namespace parameters [#3360](prometheus/node_exporter#3360)
- \[BUGFIX] netdev: Respect deviceFilter for `node_network_address_info` metric [#3340](prometheus/node_exporter#3340)
- \[BUGFIX] mountstats: Fix multiple transports statistics labeling [#3358](prometheus/node_exporter#3358)
- \[BUGFIX] diskstats: Fix panic when using device-include flag only [#3603](prometheus/node_exporter#3603)
R167 added a commit to R167/node_exporter that referenced this pull request Apr 8, 2026
prometheus#3603 introduced a subtle regression for existing configs where device-exclude was intentionally set to `=''` to clear the Linux default. This breaks configs that are valid (exclude is intentionally cleared). Update the mutual exclusivity check to only fail when the value is non-empty.

Signed-off-by: winston <me@winstondurand.com>
SuperQ pushed a commit that referenced this pull request Apr 8, 2026
#3603 introduced a subtle regression for existing configs where device-exclude was intentionally set to `=''` to clear the Linux default. This breaks configs that are valid (exclude is intentionally cleared). Update the mutual exclusivity check to only fail when the value is non-empty.

Signed-off-by: winston <me@winstondurand.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants