Skip to content

fix(vmware): skip independent-nonpersistent disks to avoid backup noise#502

Closed
Littlericket wants to merge 1 commit intobb-Ricardo:developmentfrom
Littlericket:fix/skip-independent-nonpersistent-disks
Closed

fix(vmware): skip independent-nonpersistent disks to avoid backup noise#502
Littlericket wants to merge 1 commit intobb-Ricardo:developmentfrom
Littlericket:fix/skip-independent-nonpersistent-disks

Conversation

@Littlericket
Copy link
Copy Markdown
Contributor

Problem

When VMs are backed up with tools like Veeam, temporary Independent-nonpersistent disks are attached during the backup window. If netbox-sync runs at that time it:

  1. Adds those disks as NBVirtualDisk objects in NetBox.
  2. On the next run (after the backup), removes them.

This produces two unnecessary changelog entries per backup job and causes constant churn in environments with frequent backups or with Kubernetes clusters using CSI drivers (PVCs attach/detach continuously).

Solution

Detect disks with diskMode == independent_nonpersistent during the VMware inventory scan and handle them gracefully:

  1. Skip collection — the disk is not added to disk_data; its label is recorded in a skipped_independent_disks set.
  2. Clean up stale NetBox entriesadd_device_vm_to_inventory receives the set and marks any pre-existing NetBox VirtualDisk with a matching name as deleted = True, so stale entries from previous runs are removed cleanly.
  3. Widen the trigger condition — the disk sync block now runs if len(disk_data) > 0 or len(skipped_independent_disks) > 0, ensuring cleanup fires even when all disks on a VM were skipped.

Relation to #450

PR #450 adds opt-in config options (vm_exclude_disk_sync / vm_exclude_disk_sync_by_tag) to skip disk sync for specific VMs entirely. This PR is complementary: it handles a specific, well-defined disk mode that should always be skipped regardless of VM name or tag, without requiring any configuration change.

The two PRs touch the same section of add_device_vm_to_inventory and can be merged independently; combining them would give users both automatic skip of independent-nonpersistent disks and the ability to exclude whole VMs from disk sync.

Changes

  • module/sources/vmware/connection.py only — no config changes, no documentation changes required.

@Littlericket Littlericket requested a review from bb-Ricardo as a code owner April 8, 2026 05:39
@Littlericket Littlericket force-pushed the fix/skip-independent-nonpersistent-disks branch from f74fce1 to fbc275e Compare April 8, 2026 05:41
VMs backed up with tools like Veeam temporarily attach
'Independent-nonpersistent' disks during the backup window. When
netbox-sync runs at that time it adds and then immediately deletes
NetBox VirtualDisk objects, producing two unnecessary changelog entries
per backup job.

This fix detects disks with diskMode == 'independent_nonpersistent'
during the VMware inventory scan and:
1. Skips adding them to the discovered disk list.
2. Tracks their device labels in a set (skipped_independent_disks).
3. Passes that set to add_device_vm_to_inventory so any pre-existing
   NetBox entry for such a disk is marked for deletion instead of being
   compared against a new entry.

Fixes: disk churn caused by backup tooling (e.g. Veeam) attaching
independent-nonpersistent snapshot helper disks.
@Littlericket Littlericket force-pushed the fix/skip-independent-nonpersistent-disks branch from fbc275e to f94e5cc Compare April 8, 2026 05:42
@Littlericket
Copy link
Copy Markdown
Contributor Author

Thats what happens when you let an agent do a PR - and formats the whole file beforehand. I will reopen manually. Sorry.

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.

1 participant