Bug 2033568

Summary: Repository sync gets failed due to pulp error "Cannot delete some instances of model 'ReservedResource' because they are referenced through a protected foreign key"
Product: Red Hat Satellite Reporter: Devendra Singh <desingh>
Component: PulpAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Lai <ltran>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.10.1CC: dkliban, ggainey, mjia
Target Milestone: UnspecifiedKeywords: AutomationBlocker, Regression, Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-01-10 15:55:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Devendra Singh 2021-12-17 09:33:51 UTC
Description of problem: Repository sync gets failed due to pulp error "Cannot delete some instances of model 'ReservedResource' because they are referenced through a protected foreign key"


Version-Release number of selected component (if applicable):
6.10

How reproducible:
always

Steps to Reproduce:
1- Prepare the Satellite and Capsule using the latest 6.9.z GA version.
2- Run the sync for all the repositories and it completes successfully.
3- Run the pulp migration and that completes successfully.
4. Upgrade the satellite from 6.9.z GA to 6.10.1.1 GA
5. Run the Repository sync for the "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server" repository.
6. Repository sync gets failed due to the below error

pulpcore-worker-2: pulp [None]: pulpcore.tasking.entrypoint:INFO: Starting distributed type worker
pulpcore-worker-2: pulp [None]: pulpcore.tasking.worker_watcher:INFO: New worker '2916' discovered
pulpcore-worker-5: pulp [None]: pulpcore.tasking.pulpcore_worker:INFO: Clean offline worker 14817.
pulpcore-worker-5: Traceback (most recent call last):
pulpcore-worker-5: File "/usr/bin/pulpcore-worker", line 11, in <module>
pulpcore-worker-5: load_entry_point('pulpcore==3.14.9', 'console_scripts', 'pulpcore-worker')()
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/click/core.py", line 829, in __call__
pulpcore-worker-5: return self.main(*args, **kwargs)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/click/core.py", line 782, in main
pulpcore-worker-5: rv = self.invoke(ctx)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
pulpcore-worker-5: return ctx.invoke(self.callback, **ctx.params)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/click/core.py", line 610, in invoke
pulpcore-worker-5: return callback(*args, **kwargs)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/pulpcore/tasking/entrypoint.py", line 44, in worker
pulpcore-worker-5: NewPulpWorker().run_forever()
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 277, in run_forever
pulpcore-worker-5: self.sleep()
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 187, in sleep
pulpcore-worker-5: self.beat()
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 100, in beat
pulpcore-worker-5: self.worker_cleanup()
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/pulpcore/tasking/pulpcore_worker.py", line 90, in worker_cleanup
pulpcore-worker-5: worker.delete()
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/django_lifecycle/mixins.py", line 146, in delete
pulpcore-worker-5: value = super().delete(*args, **kwargs)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/django/db/models/base.py", line 921, in delete
pulpcore-worker-5: collector.collect([self], keep_parents=keep_parents)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/django/db/models/deletion.py", line 224, in collect
pulpcore-worker-5: field.remote_field.on_delete(self, field, sub_objs, self.using)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/django/db/models/deletion.py", line 16, in CASCADE
pulpcore-worker-5: source_attr=field.name, nullable=field.null)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/django/db/models/deletion.py", line 224, in collect
pulpcore-worker-5: field.remote_field.on_delete(self, field, sub_objs, self.using)
pulpcore-worker-5: File "/usr/lib/python3.6/site-packages/django/db/models/deletion.py", line 27, in PROTECT
pulpcore-worker-5: sub_objs
pulpcore-worker-5: django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'ReservedResource' because they are referenced through a protected foreign key: 'TaskReservedResource.resource'", <QuerySet [<TaskReservedResource: pk=c8d7b1db-6cc4-4174-810b-85c295fcc2fb>]>)
systemd: pulpcore-worker: main process exited, code=exited, status=1/FAIL


Actual results:
The RHEL7 repository sync got failed due to the "Cannot delete some instances of model 'ReservedResource' because they are referenced through a protected foreign key" error.

Expected results:

Repository sync should be completed successfully.

Additional info:
Repository sync only gets failed for "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server" for other Rhel and custom repo it works perfectly.