-
Notifications
You must be signed in to change notification settings - Fork 124
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
Conversation
@@ -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)) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this 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?
Yes, please file an issue |
9444b8e
to
2d21c03
Compare
pulp_rpm/app/models/distribution.py
Outdated
@@ -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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ipanova wdyt?
There was a problem hiding this comment.
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.
2d21c03
to
53f782d
Compare
53f782d
to
0c4e26e
Compare
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.