Skip to content

fix(systemjobs): expand SyncObjectsJob to enumerate Device/VM descendants#123

Open
berlikm wants to merge 4 commits into
OpensourceICTSolutions:developmentfrom
berlikm:fix/background-sync-enumerate-devices
Open

fix(systemjobs): expand SyncObjectsJob to enumerate Device/VM descendants#123
berlikm wants to merge 4 commits into
OpensourceICTSolutions:developmentfrom
berlikm:fix/background-sync-enumerate-devices

Conversation

@berlikm

@berlikm berlikm commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Rewrites SyncObjectsJob to 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() iterated ZabbixServerAssignment.objects.all() and enqueued obj.assigned_object directly. When the assignment targets a SiteGroup, a SiteGroup object was enqueued — which then crashed SyncHostJob (AttributeError: 'SiteGroup' has no attribute 'status'). Also: return was used instead of continue on 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.
  • Deduplication via set() keyed by (app_label, model, pk) — replaces the buggy return
  • Deterministic RQ job IDs (nbxsync-host-{app_label}-{model}-{pk}) suppress duplicate active jobs
  • Worker changed from passing model instances to passing (app_label, model_name, object_id) tuples — avoids stale pickled objects
  • Tests updated to new argument format

Dependencies

Standalone on development. No dependencies on other PRs.

Testing

22 new tests. All existing tests pass.

Part of #121.

berlikm added 3 commits July 14, 2026 19:44
…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).
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