nautobot-app-ssot
nautobot-app-ssot copied to clipboard
SNOW SSoT Caching
Environment
- Python version: 3.12
- Nautobot version: 2.3
- nautobot-ssot version: 2.8.0
Expected Behavior
- Not to cache cmdb_ci / sys_id between runs
- Not to use old cmdb_ci / sys_id when creating interface records
Observed Behavior
- In job one, ssot collects a sys_id
- In between the device is deleted
- in job two, the memory from job 1 is used, that has the cached sys_id for creating interfaces only (e.g. not to create the device, which is created properly created) points the FK relationship to the old sys_id, leaving it in no mans land
Steps to Reproduce
- Sync job
- Delete device in snow
- Run job in same worker with same memory foot print
Ways to work around
Set --max-tasks-per-child on celery worker.
ServiceNowCRUDMixin._sys_id_cache and ServiceNowDiffSync.objects_to_delete should both become instance attributes and/or be explicitly emptied out at job start time.
@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.