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

Mutable Prototype #389

Closed
wants to merge 6 commits into from
Closed

Mutable Prototype #389

wants to merge 6 commits into from

Conversation

fao89
Copy link
Member

@fao89 fao89 commented Oct 9, 2020

@pulpbot
Copy link
Member

pulpbot commented Oct 9, 2020

Attached issue: https://pulp.plan.io/issues/7504

Comment on lines +362 to +373
def get_queryset(self):
"""
Returns a MutableCollectionMetadata queryset for specified distribution.
"""
return RepositoryVersion.objects.filter(
pk=self.get_repository_version(self.kwargs["path"]).pk
).prefetch_related(
Prefetch(
"collection_memberships",
queryset=MutableCollectionMetadata.objects.filter(deprecated=True),
)
)
Copy link
Member Author

@fao89 fao89 Oct 12, 2020

Choose a reason for hiding this comment

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

Problem: only displays deprecated for the last RepositoryVersion
Question: how to determine which content remains at the Repository, to get the correspondent MutableCollectionMetadata?

@@ -38,6 +38,11 @@
]

v3_urls = [
path(
"metadata/",
views_v3.MutableCollectionMetadataViewset.as_view({"get": "list"}),
Copy link
Member Author

Choose a reason for hiding this comment

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

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Sync should check for the last_updated

if self.request.query_params.get("deprecated", "").lower() in ["true", "yes", "1"]:
deprecated = True

return queryset.filter(collection__mutablecollectionmetadata__deprecated=deprecated)
Copy link
Member Author

Choose a reason for hiding this comment

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

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Bring all collections by default, only filter deprecation with query params

@fao89 fao89 requested a review from a team October 12, 2020 20:18
import uuid


class Migration(migrations.Migration):
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a step here to migrate the deprecation status over to MutableCollectionMetadata before the deprecated field is removed from the collections table.

Comment on lines +238 to +250
class MutableCollectionMetadata(BaseModel):
"""
A model that represents Collection mutable metadata for a given RepositoryVersion.
"""

repository_version = models.ForeignKey(
RepositoryVersion, on_delete=models.CASCADE, related_name="collection_memberships"
)
collection = models.ForeignKey(Collection, on_delete=models.CASCADE)
deprecated = models.BooleanField(default=False)

class Meta:
unique_together = ("collection", "repository_version")
Copy link
Member Author

Choose a reason for hiding this comment

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

  • Should we make it sparse?
  • What about CollectionVersion metadata?

Comment on lines +391 to +397
metadata_downloader = remote.get_downloader(
url=get_metadata_url(url), silence_errors_for_response_status_codes={404}
)
try:
mutable_data = parse_metadata(await metadata_downloader.run())
except FileNotFoundError:
mutable_data = {}
Copy link
Member Author

@fao89 fao89 Oct 14, 2020

Choose a reason for hiding this comment

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

Sync should consider last_updated for optimization

from pulp_ansible.app.models import AnsibleRepository, MutableCollectionMetadata


def add_and_remove(repository_pk, add_content_units, remove_content_units, base_version_pk=None):
Copy link
Member Author

Choose a reason for hiding this comment

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

Used in synclist - "custom" sync between repositories

@fao89
Copy link
Member Author

fao89 commented Oct 26, 2020

closing in favor of #392

@fao89 fao89 closed this Oct 26, 2020
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.

None yet

3 participants