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

PROTECT Method Breaks New Log Cleanup Job #528

Closed cmong-nextech closed 1 week ago

cmong-nextech commented 2 weeks ago

Environment

Expected Behavior

Log Cleanup job runs without issue.

Observed Behavior

Job fails and references the SSOT FK Sync.job_result

Steps to Reproduce

  1. Utilize the SSOT plugin to sync something to nautobot, creating a job log in the process.
  2. Run the Log Cleanup job introduced into Nautobot in version 2.3.1
  3. Witness the following error:
    {
    "exc_message": [
        "Cannot delete some instances of model 'JobResult' because they are referenced through protected foreign keys: 'Sync.job_result'.",
        [
            {
                "__nautobot_type__": "nautobot_ssot.models.Sync",
                "display": "Sync Network Data From Network → Nautobot, 2024-07-31 23:43",
                "id": "b9a07bc5-1640-43b7-b701-b6f947102016"
            },
Kircheneer commented 1 week ago

We could change the foreign key from Sync to cascade when the JobResult is deleted and put a warning into the docs about this. This would in my mind be the most straight-forward behavior. @jdrew82, @glennmatthews any thoughts?

glennmatthews commented 1 week ago

Sounds appropriate to me.

jdrew82 commented 1 week ago

We could change the foreign key from Sync to cascade when the JobResult is deleted and put a warning into the docs about this. This would in my mind be the most straight-forward behavior. @jdrew82, @glennmatthews any thoughts?

I agree that this makes the most sense.