fix(vmware): skip independent-nonpersistent disks to avoid backup noise#502
Closed
Littlericket wants to merge 1 commit intobb-Ricardo:developmentfrom
Closed
Conversation
f74fce1 to
fbc275e
Compare
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.
fbc275e to
f94e5cc
Compare
Contributor
Author
|
Thats what happens when you let an agent do a PR - and formats the whole file beforehand. I will reopen manually. Sorry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
NBVirtualDiskobjects in NetBox.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_nonpersistentduring the VMware inventory scan and handle them gracefully:disk_data; its label is recorded in askipped_independent_disksset.add_device_vm_to_inventoryreceives the set and marks any pre-existing NetBoxVirtualDiskwith a matching name asdeleted = True, so stale entries from previous runs are removed cleanly.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_inventoryand 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.pyonly — no config changes, no documentation changes required.