Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-31985

Remove orphan task failed with 'Cannot delete some instances of model 'RpmRepository' because they are referenced through restricted foreign keys: 'Variant.repository'.", {<Variant: Server>}' error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 6.16.0
    • Pulp
    • False
    • sat-artemis
    • None
    • None
    • None
    • To Do

      Description of problem:

      Remove orphan task failed with following error:{}
      error:

      traceback: |2
      File "/usr/lib/python3.11/site-packages/pulpcore/tasking/tasks.py", line 66, in _execute_task
      result = func(*args, **kwargs)
      ^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pulpcore/app/tasks/orphan.py", line 66, in orphan_cleanup
      bulk_content.delete()
      File "/usr/lib/python3.11/site-packages/django/db/models/query.py", line 1148, in delete
      deleted, _rows_count = collector.delete()
      ^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/django/db/models/deletion.py", line 512, in delete
      signals.post_delete.send(
      File "/usr/lib/python3.11/site-packages/django/dispatch/dispatcher.py", line 176, in send
      return [
      ^
      File "/usr/lib/python3.11/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
      (receiver, receiver(signal=self, sender=sender, **named))
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pulp_rpm/app/models/distribution.py", line 349, in cleanup_subrepos
      repos.delete()
      File "/usr/lib/python3.11/site-packages/django/db/models/query.py", line 1147, in delete
      collector.collect(del_query)
      File "/usr/lib/python3.11/site-packages/django/db/models/deletion.py", line 392, in collect
      raise RestrictedError(
      description: '("Cannot delete some instances of model ''RpmRepository'' because
      they are referenced through restricted foreign keys: ''Variant.repository''.",
      {<Variant: Server>, <Variant: Server>})'
      worker: "/pulp/api/v3/workers/01958317-b2bc-7459-82b8-57c92f37c314/"

      This issue appears to happen when multiple orphan distribution trees that were associated to same repository in different repository version and pointing to the same sub repository.

      Remove orphan task removes contents in 2000 batch size. if those distribution trees are deleted in the same batch then then the sub repository can be deleted without issue.

      If those distribution trees are split into different batch, then the deletion of the sub repository will fail.

       

      How reproducible:

      Easy

       

      Is this issue a regression from an earlier version:

      Not sure

       

      Steps to Reproduce:

      1. Enable and sync a kickstart repository with sub repositories, such as RHEL 6.6 kickstart repo.

      2.  To simulate the db migration of "https://github.com/pulp/pulp_rpm/commit/8667aa13c865fb4960542f4da68d861ccc34bcfc",  Find the "images/install.img" entry for the RHEL 6.6 kickstart repo in the "rpm_distributiontree" table and update the digest to "temp str 00000000000000000000000000000044, to be removed at sync"

      3. Complete resync the RHEL 6.6 kickstart repo.

      4. To force 100% reproducible, edit "/usr/lib/python3.11/site-packages/pulpcore/app/tasks/orphan.py" file and set the batchsize to 1:

      def queryset_iterator(qs, batchsize=1, gc_collect=True):

      5. Restart all Pulp services.

      6. Trigger the remove orphan task

       

      Actual behavior:
      Cannot delete some instances of model ''RpmRepository'' because they are referenced through restricted foreign keys: ''Variant.repository''.", {<Variant: Server>, <Variant: Server>})

      Expected behavior:
      Run successfully{}

       

              Unassigned Unassigned
              rhn-support-hyu Hao Chang Yu
              Hao Chang Yu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: