Repository navigation
Conversation
removeDeviceCharts matched chart IDs by an unterminated prefix, "device_<name>", so removing wg1 also marked every chart of wg10-wg19 as obsolete. The surviving device stays in c.devices, so its charts were never re-created until the plugin restarted. Match the exact chart IDs built from deviceChartsTmpl instead, as in ntpd and nvme. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant C as Collector
participant D as Device Manager
participant Ch as Chart Store
participant T as Chart Templates
Note over C,T: WireGuard Chart Cleanup Flow
C->>D: Collect() - fetch devices
D-->>C: device list (wg1, wg10)
loop Each device
C->>C: Track active devices
end
alt Device wg1 removed at runtime
C->>C: Detect wg1 no longer in device list
C->>C: Call removeDeviceCharts("wg1")
Note over C,T: NEW: Build exact chart ID set
C->>T: Read deviceChartsTmpl definitions
T-->>C: Chart templates (network_io, peers, etc.)
loop Each chart template
C->>C: Generate exact chart ID (e.g., device_wg1_network_io)
C->>C: Add to lookup set
end
C->>Ch: Iterate all existing charts
alt Chart ID matches exact set
C->>Ch: MarkRemove() + MarkNotCreated()
Note over Ch: Only charts for wg1 affected
else Chart ID doesn't match
Note over Ch: Keep charts (e.g., device_wg10_*)
end
end
opt Device wg10 still active
C->>Ch: Keep wg10 charts in registry
Note over Ch: Charts survive cleanup
end
|
|
@b84330808 I think the proper fix is to convert collectors to v2. v2 doesn't have this problem. |
|
Makes sense, thanks. Should I close this one (and #24539, the same thing for docker)? If a v2 conversion of the wireguard collector would be welcome as a PR, I can try that instead. |
|
Yes, you can close all of them. There's a skill in the repo for converting v1 to v2, so Claude should be able to figure it out. Also, ask Claude to remove the AI contribution attribution from commits. |
|
Closing as discussed; I'll look at the v2 conversion instead. Thanks! |


Summary
Follow-up to #24542 (same bug class, refs #24230).
wireguardremoveDeviceChartsmatches chart IDs by the unterminated prefixdevice_<name>, so removingwg1also marks every chart ofwg10-wg19obsolete. The surviving device stays inc.devices, so its charts are never added again until go.d.plugin restarts.It now matches the exact chart IDs built from
deviceChartsTmpl, like ntpd and nvme in #24542. Peer chart IDs contain the full 44-character public key, soremovePeerChartscan't hit another peer this way and is left alone.Test Plan
New
TestCollector_Collectcase "device removed at run time, device with a longer name is kept": it collectswg1andwg10, dropswg1, runs the cleanup, and checks that only thedevice_wg1_*charts are obsolete. On master it fails (device_wg10_network_ioanddevice_wg10_peersare obsolete too); with the fix it passes.go test -count=1 ./plugin/go.d/collector/wireguard/andgo vetpass.Additional Information
I used Claude Code to write this change.
For users: How does this change affect me?
wg10afterwg1) no longer disappear.Summary by cubic
Fixes the WireGuard collector so removing a device only removes that device's charts, not the charts of devices with longer names that share the same prefix (e.g., removing
wg1no longer markswg10charts as obsolete).deviceChartsTmplinstead of using an unterminated prefix match.Written for commit 0471c56. Summary will update on new commits.
Summary by CodeRabbit