nautobot / nautobot-app-ssot

Single Source of Truth for Nautobot
https://docs.nautobot.com/projects/ssot/en/latest/
Other
35 stars 33 forks source link

SNOW SSoT Caching #513

Open itdependsnetworks opened 3 weeks ago

itdependsnetworks commented 3 weeks ago

Environment

Expected Behavior

Observed Behavior

Steps to Reproduce

  1. Sync job
  2. Delete device in snow
  3. Run job in same worker with same memory foot print

Ways to work around

Set --max-tasks-per-child on celery worker.

glennmatthews commented 3 weeks ago

ServiceNowCRUDMixin._sys_id_cache and ServiceNowDiffSync.objects_to_delete should both become instance attributes and/or be explicitly emptied out at job start time.

itdependsnetworks commented 3 weeks ago

@glennmatthews Would something like this work?

class ServiceNowCRUDMixin:
    """Mixin class for all ServiceNow models, to support CRUD operations based on mappings.yaml."""

    _sys_id_cache = {}
    """Dict of table -> column_name -> value -> sys_id."""

    def model_rebuild(cls):
        super().model_rebuild()
        cls._sys_id_cache = {}

we are calling model_rebuild at the end of the file anyway.