Skip to content

Conversation

@muratbulat
Copy link
Contributor

Problem

When a source (for example vCenter) is temporarily unavailable due to network issues, authentication errors, or maintenance, netbox-sync may fail to initialize that source and receive an empty inventory.
If pruning is enabled, this can incorrectly mark a large number of existing objects (VMs, interfaces, IP addresses) as orphaned and prune them from NetBox, even though the source outage is temporary.

Solution

This pull request introduces a safety guard that skips the prune step when one or more enabled sources fail to initialize during a sync run.
Pruning is only executed when enabled sources are successfully initialized, preventing accidental mass orphaning or deletions caused by transient source failures.

Behavior

No change when all enabled sources initialize successfully; pruning works as before.

If any enabled source fails to initialize, the prune step is skipped for that run and a warning is logged.

Pruning resumes automatically on the next successful run.

Configuration

A new optional configuration flag is added under the [netbox] section:

skip_prune_on_source_failure = True

When enabled, pruning is skipped if at least one enabled source fails initialization.

Rationale

This change is intentionally safety-first and conservative. It does not alter normal prune behavior during healthy runs and helps protect NetBox data integrity during temporary source outages.

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