fix(systemjobs): expand SyncObjectsJob to enumerate Device/VM descendants#123
Open
berlikm wants to merge 4 commits into
Open
Conversation
…ants - Add _get_eligible_instances() to turn SiteGroup/Site/Region/Role/Platform/ Manufacturer/DeviceType/Cluster/ClusterType assignments into Device/VM qs. - Rewrite SyncObjectsJob.run() to enqueue eligible instances, deduplicate by (app_label, model, pk), and check sync_enabled on both assignment + server. - Fix duplicate path: return -> continue. - Update tests and docs for production interval recommendation (360 min).
berlikm
added a commit
to berlikm/nbxsync
that referenced
this pull request
Jul 15, 2026
berlikm
force-pushed
the
fix/background-sync-enumerate-devices
branch
from
July 16, 2026 07:34
3555cb8 to
a9bd576
Compare
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.
Summary
Rewrites
SyncObjectsJobto expand assignment objects (SiteGroup, Site, Region, DeviceRole, Platform, Manufacturer, DeviceType, Cluster, ClusterType) into their descendant Device/VM instances before enqueueing.Problem
The original
SyncObjectsJob.run()iteratedZabbixServerAssignment.objects.all()and enqueuedobj.assigned_objectdirectly. When the assignment targets a SiteGroup, a SiteGroup object was enqueued — which then crashedSyncHostJob(AttributeError: 'SiteGroup' has no attribute 'status'). Also:returnwas used instead ofcontinueon duplicate detection, aborting the entire job.Changes
_get_eligible_instances(assignment)— expands SiteGroup → Sites → Devices + VMs, Region → Sites → Devices + VMs, DeviceRole → descendant roles → Devices + VMs, etc.set()keyed by(app_label, model, pk)— replaces the buggyreturnnbxsync-host-{app_label}-{model}-{pk}) suppress duplicate active jobs(app_label, model_name, object_id)tuples — avoids stale pickled objectsDependencies
Standalone on
development. No dependencies on other PRs.Testing
22 new tests. All existing tests pass.
Part of #121.