Issue #6629
closedcan't delete kickstart repository
Description
Ticket moved to GitHub: "pulp/pulp_rpm/2246":https://github.com/pulp/pulp_rpm/issues/2246
When I tried to delete a kickstart repository I got the following error in my Task:
(pulp) [vagrant@pulp2-nightly-pulp3-source-centos7 ~]$ http :/pulp/api/v3/tasks/c59c1a92-1ce5-4424-a948-7fbf1124b4f5/ HTTP/1.1 200 OK Allow: GET, PATCH, DELETE, HEAD, OPTIONS Connection: Keep-Alive Content-Length: 1755 Content-Type: application/json Date: Fri, 01 May 2020 20:13:22 GMT Keep-Alive: timeout=5, max=10000 Server: gunicorn/20.0.4 Vary: Accept,Cookie X-Frame-Options: SAMEORIGIN { "child_tasks": [], "created_resources": [], "error": { "description": "(\"Cannot delete some instances of model 'Repository' because they are referenced through a protected foreign key: 'Variant.repository'\", ]>)", "traceback": " File \"/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/worker.py\", line 886, in perform_job\n rv = job.perform()\n File \"/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/job.py\", line 664, in perform\n self._result = self._execute()\n File \"/usr/local/lib/pulp/lib64/python3.6/site-packages/rq/job.py\", line 670, in _execute\n return self.func(*self.args, **self.kwargs)\n File \"/home/vagrant/devel/pulpcore/pulpcore/app/tasks/repository.py\", line 22, in delete\n models.Repository.objects.filter(pk=repo_id).delete()\n File \"/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/query.py\", line 710, in delete\n collector.collect(del_query)\n File \"/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/deletion.py\", line 224, in collect\n field.remote_field.on_delete(self, field, sub_objs, self.using)\n File \"/usr/local/lib/pulp/lib64/python3.6/site-packages/django/db/models/deletion.py\", line 27, in PROTECT\n sub_objs\n" }, "finished_at": "2020-05-01T20:13:12.201492Z", "name": "pulpcore.app.tasks.repository.delete", "parent_task": null, "progress_reports": [], "pulp_created": "2020-05-01T20:13:11.926923Z", "pulp_href": "/pulp/api/v3/tasks/c59c1a92-1ce5-4424-a948-7fbf1124b4f5/", "reserved_resources_record": [ "/pulp/api/v3/repositories/rpm/rpm/9581879e-4b4c-4f53-86e9-90319e835ffb/" ], "started_at": "2020-05-01T20:13:12.082540Z", "state": "failed", "task_group": null, "worker": "/pulp/api/v3/workers/82124443-d497-4889-9075-bed24a6cb29c/" }
Updated by ttereshc almost 4 years ago
Probably a custom delete endpoint for RpmRepository can solve it. I would guess that sub repos needs to be removed first and then the repo which has them can be removed as well. It should all happen as a one transaction.
Updated by dkliban@redhat.com almost 4 years ago
- Triaged changed from No to Yes
This issue occurs when the user is trying to delete a subrepo that is associated with the DistributionTree.
We need to confirm that subrepos don't show up in the RPM repository list API. If they do, we should exclude them.
We should also have the REST API check if the repository being deleted is a subrepo, and if it is, it should not dispatch a task to perform the delete. Instead it should tell the user the operation is not allowed. Better yet, maybe a 404?
Updated by pulpbot over 2 years ago
- Description updated (diff)
- Status changed from NEW to CLOSED - DUPLICATE