Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify subrepo deletion #3343

Merged
merged 1 commit into from
Dec 8, 2023
Merged

Simplify subrepo deletion #3343

merged 1 commit into from
Dec 8, 2023

Conversation

gerrod3
Copy link
Contributor

@gerrod3 gerrod3 commented Nov 29, 2023

The previous cleanup method was being called multiple times for each addon & varriant present in a DistributionTree, now it should only be called once per DistributionTree deleted.

@dralley dralley requested review from ipanova and dralley and removed request for ipanova November 29, 2023 23:34
@@ -107,8 +107,8 @@ def repositories(self):
"""
from pulp_rpm.app.models import RpmRepository

repo_ids = list(self.addons.values_list("repository__pk", flat=True))
repo_ids += list(self.variants.values_list("repository__pk", flat=True))
repo_ids = list(self.addons.values_list("repository_id", flat=True))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -331,19 +331,10 @@ class Meta:
)


@receiver(post_delete, sender=Addon)
@receiver(post_delete, sender=Variant)
@receiver(pre_delete, sender=DistributionTree)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Member

@ipanova ipanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you going to add an issue?

@dralley
Copy link
Contributor

dralley commented Dec 1, 2023

Yes, please file an issue

@gerrod3 gerrod3 force-pushed the better-tree-delete branch 2 times, most recently from 9444b8e to 2d21c03 Compare December 1, 2023 21:32
@@ -255,7 +255,7 @@ class Addon(BaseModel):
distribution_tree = models.ForeignKey(
DistributionTree, on_delete=models.CASCADE, related_name="addons"
)
repository = models.ForeignKey(Repository, on_delete=models.PROTECT, related_name="addons")
repository = models.ForeignKey(Repository, on_delete=models.DO_NOTHING, related_name="addons")
Copy link
Contributor

@dralley dralley Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait - why? The repository link is a fundamental piece of this object (unfortunately). I'm a bit worried this opens us up to integrity issues

If we can keep the nice properties of your new approach while leaving these protections in place and deleting the Addons and Variants first, let's do that if possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ipanova wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've switched it to use RESTRICT so you can't mindlessly delete the sub-repository unless the DistributionTree is being deleted. https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.RESTRICT

I had to change the signal logic slightly to do some sleight of hand operations to be able to still find the subrepos to delete.

@dralley dralley merged commit d6f719f into pulp:main Dec 8, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants