pulp / pulp/pulp_ansible

Collection model that has no CollectionVersion related objects needs to be removed somehow when orphaned

Open
#693 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue Migrated from Redmine Severity: Low
Dominant language
Python
Stars
68
Forks
62
Avg merge
1d 14h
Merged PRs (30d)
37

Description

Author: @bmbouter (bmbouter)

Redmine Issue: 5521, https://pulp.plan.io/issues/5521


Problem

1. Upload a collection with <namespace=foo, name=bar, and version=1.0> and associate it with a repository_version so it's not an orphan.
2. Upload a second collection with <namespace=foo, name=bar, and version=2.0> and associate it with a repository_version so it's not an orphan.

At this point I expect the /pulp/api/v3/ansible/collection_versions to show you two CollectionVersions. Once story 5520 is implemented you would see exactly 1 Collection (deduplicated since they share Collection.

3. Now unassociate the version=1.0 collection
4. Run orphan cleanup and verify the Collection verson=1.0 was deleted from Pulp entirely. Now you'll have 1 Collection and 1 CollectionVersion
5. Now unassociate the version=2.0 collection
6. Run orphan cleanup again and verify the Collection version=2.0 was deleted from Pulp entirely.
7. Now list a Collection using the endpoint from 5520 and observe it still shows the Collection even though there are 0 CollectionVersions, this is the bug.

Solutions

Add a post_delete hook on CollectionVersion that will identify if it's the last CollectionVersion referring to that Collection and delete the Collection also if so.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the CollectionVersion and Collection models and the orphan cleanup path. Read the Django post_delete signal documentation and trace how unassociated CollectionVersions are removed. Done means orphan cleanup removes the final CollectionVersion and its now-empty Collection, and the collection endpoint no longer lists it.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.