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
Add namespace to distributions #158
Conversation
|
Attached issue: https://pulp.plan.io/issues/7089 |
50e4d0f
to
91d6204
Compare
|
I just realized, that if paths without a "/" still had a namespace (in that case with the same name), the uniqueness would be trivially given by the database. |
8091149
to
d2db1fc
Compare
pulp_container/app/serializers.py
Outdated
| base_path = validated_data["base_path"] | ||
|
|
||
| if "namespace" in validated_data: | ||
| if not base_path.startswith(validated_data["namespace"].name + "/"): |
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 know this change is not really related to the PR but can you please update and remove the publication reference https://github.com/pulp/pulp_container/pull/158/files#diff-90a314d7b2d5ddb20d360be02a4ec146R344 |
2cc876b
to
8d56ba8
Compare
| ViewSet for ContainerNamespaces. | ||
| """ | ||
|
|
||
| endpoint_name = "pulp_container/namespaces" |
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.
the changes look good to me, @dkliban do you want to take a look? do you have a different suggestion on the endpoint or we leave this one as is?
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 looked at 'django-admin show_urls' and i would not be opposed also having /namespaces/container/ as another option to consider
pulp_container/app/serializers.py
Outdated
| namespace_serializer.is_valid(raise_exception=True) | ||
| validated_data["namespace"] = namespace_serializer.create( | ||
| namespace_serializer.validated_data | ||
| ) |
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.
there's room here for a race condition, if two repos are being created with a new namespace at the same time it could result in one of the 'creates' to fail when the other task created it. Not sure how often ya'll deal with that within pulp, but we see it all the time within katello
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.
Sounds like we really need a sophisticated get_or_create on the serializer model.
I think we do that in >=3 places.
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 added another except block to recognize a lost race.
589931d
to
b1bdaf9
Compare
I suggest adding pulp_href pulp_created and maybe list of distributions |
pulp_container/app/serializers.py
Outdated
| result = cls.Meta.model.objects.get(**natural_key) | ||
| except ObjectDoesNotExist: | ||
| data = {} | ||
| if default_values is not None: |
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.
if default_values:
| """ | ||
|
|
||
| TYPE = "container" | ||
|
|
||
| namespace = models.ForeignKey( | ||
| ContainerNamespace, | ||
| on_delete=models.CASCADE, |
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.
👍
| data = {} | ||
| if default_values is not None: | ||
| data.update(default_values) | ||
| data.update(natural_key) |
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.
data seems to be unused
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.
But it should be... Changing that.
pulp_container/app/serializers.py
Outdated
| """ | ||
|
|
||
| class Meta: | ||
| fields = ModelSerializer.Meta.fields + ["name"] |
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.
we should use a tuple here instead of list
As the list of distributions can get very large, i think it would be better to make the distribution filterable by namespace. |
That's a fine idea, for that we would need to add NamespaceFilter to the DistributionViewset. |
|
while i can filter the distributions by the name of the namespace i get 500 on the namespace endpoint |
|
Somehow the |
47e9faf
to
ba009c8
Compare
| Serializer for ContainerNamespaces. | ||
| """ | ||
|
|
||
| pulp_href = IdentityField(view_name="pulp_container/namespaces-detail") |
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 this should fix it.
fixes #7089
https://pulp.plan.io/issues/7089
This is the first version to pass ci. Still missing are at least:
- [ ] validation of namespaces to be collision free with non namespaced distribution- The new design handles this on the database table level.