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

Cannot upload content via pulp-container because of the change made to the Upload model #5267

Closed
lubosmj opened this issue Apr 16, 2024 · 2 comments · Fixed by #5272
Closed

Comments

@lubosmj
Copy link
Member

lubosmj commented Apr 16, 2024

The following commit broke the pulp-container upload: 9192c2b.

Traceback:

pulp_1    | pulp [adbae673f9b7498d8240989c1bba93ff]: django.request:ERROR: Internal Server Error: /v2/myorg/mygroup/ubuntu/blobs/uploads/
pulp_1    | Traceback (most recent call last):
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
pulp_1    |     response = get_response(request)
pulp_1    |                ^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
pulp_1    |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
pulp_1    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
pulp_1    |     return view_func(*args, **kwargs)
pulp_1    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/rest_framework/viewsets.py", line 124, in view
pulp_1    |     return self.dispatch(request, *args, **kwargs)
pulp_1    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
pulp_1    |     response = self.handle_exception(exc)
pulp_1    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/src/pulp_container/pulp_container/app/registry_api.py", line 271, in handle_exception
pulp_1    |     response = super().handle_exception(exc)
pulp_1    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
pulp_1    |     self.raise_uncaught_exception(exc)
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
pulp_1    |     raise exc
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
pulp_1    |     response = handler(request, *args, **kwargs)
pulp_1    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/src/pulp_container/pulp_container/app/registry_api.py", line 758, in create
pulp_1    |     upload.save()
pulp_1    |   File "/usr/lib64/python3.11/contextlib.py", line 81, in inner
pulp_1    |     return func(*args, **kwds)
pulp_1    |            ^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django_lifecycle/mixins.py", line 196, in save
pulp_1    |     self._run_hooked_methods(AFTER_CREATE, **kwargs)
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django_lifecycle/mixins.py", line 312, in _run_hooked_methods
pulp_1    |     method.run(self)
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django_lifecycle/mixins.py", line 46, in run
pulp_1    |     self.method(instance)
pulp_1    |   File "/usr/local/lib/python3.11/site-packages/django_lifecycle/decorators.py", line 119, in func
pulp_1    |     hooked_method(*args, **kwargs)
pulp_1    |   File "/src/pulpcore/pulpcore/app/models/access_policy.py", line 70, in add_perms
pulp_1    |     viewset = get_viewset_for_model(self)
pulp_1    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
pulp_1    |   File "/src/pulpcore/pulpcore/app/util.py", line 188, in get_viewset_for_model
pulp_1    |     raise LookupError("Could not determine ViewSet base name for model {}".format(model_class))

This is reproducible always when trying to push any image to the Pulp Container Registry.

Affected code:
https://github.com/pulp/pulp_container/blob/742acc52f8fc44c4d18a41621455b21e2b9133ec/pulp_container/app/models.py#L804

@lubosmj
Copy link
Member Author

lubosmj commented Apr 16, 2024

Solutions considered:

  1. make the post create hook not fail in that case
  2. teach pulp_container to do something about it
  3. we need a common super class without the mixin +1

@mdellweg

mdellweg added a commit to mdellweg/pulpcore that referenced this issue Apr 17, 2024
When e.g. pulp_container uses a subclass of Upload, we do not want the
post create hook to fail. So we just ignore if a viewset cannot be found
for the model.

fixes pulp#5267
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Apr 17, 2024
When e.g. pulp_container uses a subclass of Upload, we do not want the
post create hook to fail. So we just ignore if a viewset cannot be found
for the model.

fixes pulp#5267
@mdellweg
Copy link
Member

Solutions considered:

1. make the post create hook not fail in that case

2. teach pulp_container to do something about it

3. we need a common super class without the mixin +1

@mdellweg

I'd say it's not pulp_container's fault. So no to "2.".
"3." sounds appealing, but i have large concerns about pivoting the Upload class to something else, because these classes are tied to database tables. And an abstract base class is even worse (look for DistributionBase if you want to know more).
So IMHO we are left with "1.".

mdellweg added a commit that referenced this issue Apr 17, 2024
When e.g. pulp_container uses a subclass of Upload, we do not want the
post create hook to fail. So we just ignore if a viewset cannot be found
for the model.

fixes #5267
patchback bot pushed a commit that referenced this issue Apr 17, 2024
When e.g. pulp_container uses a subclass of Upload, we do not want the
post create hook to fail. So we just ignore if a viewset cannot be found
for the model.

fixes #5267

(cherry picked from commit 9458313)
mdellweg added a commit that referenced this issue Apr 17, 2024
When e.g. pulp_container uses a subclass of Upload, we do not want the
post create hook to fail. So we just ignore if a viewset cannot be found
for the model.

fixes #5267

(cherry picked from commit 9458313)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants