pulp / pulp_container

Pulp Container Registry
https://docs.pulpproject.org/pulp_container/
GNU General Public License v2.0
23 stars 44 forks source link

Requesting blob that doesn't exist results in 500 #1703

Closed ianballou closed 1 month ago

ianballou commented 1 month ago

Version pulpcore-selinux-2.0.1-1.el9.x86_64 python3.11-pulp-ostree-2.3.0-1.el9.noarch python3.11-pulp-deb-3.2.0-1.el9.noarch python3.11-pulp-rpm-3.25.3-1.el9.noarch python3.11-pulp-python-3.11.1-1.el9.noarch rubygem-smart_proxy_pulp-3.3.0-1.el9.noarch python3.11-pulp-container-2.20.0-1.el9.noarch python3.11-pulp-glue-0.25.3-1.el9.noarch python3.11-pulpcore-3.49.10-1.el9.noarch python3.11-pulp-ansible-0.21.5-1.el9.noarch python3.11-pulp-cli-0.25.3-1.el9.noarch

Describe the bug GETing a blob that doesn't exist triggers a 500:

Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: pulp [24486f0709c64d4f8c3ec0f626abcfc7]: django.request:ERROR: Internal Server Error: /v2/default_organization-precipitation-container_push_view-buttermilk_biscuits-arianna3/blobs/sha256:cd55268b264d4d04e2eb2a95520656af57b1a2f8f8924522c71ff8b6fbdff538
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: Traceback (most recent call last):
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/pulp_container/app/registry_api.py", line 979, in handle_safe_method
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    blob = models.Blob.objects.get(digest=pk, pk__in=repository_version.content)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    return getattr(self.get_queryset(), name)(*args, **kwargs)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    raise self.model.DoesNotExist(
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: pulp_container.app.models.Blob.DoesNotExist: Blob matching query does not exist.
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: During handling of the above exception, another exception occurred:
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: Traceback (most recent call last):
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = get_response(request)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = wrapped_callback(request, *callback_args, **callback_kwargs)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    return view_func(*args, **kwargs)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/rest_framework/viewsets.py", line 125, in view
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    return self.dispatch(request, *args, **kwargs)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = self.handle_exception(exc)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/pulp_container/app/registry_api.py", line 271, in handle_exception
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = super().handle_exception(exc)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    self.raise_uncaught_exception(exc)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    raise exc
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = handler(request, *args, **kwargs)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/pulp_container/app/registry_api.py", line 970, in get
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    return self.handle_safe_method(request, path, pk)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/pulpcore/cache/cache.py", line 171, in cached_function
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = self.make_entry(key, bk, func, args, kwargs, self.default_expires_ttl)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/pulpcore/cache/cache.py", line 204, in make_entry
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    response = handler(*args, **kwargs)
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:               ^^^^^^^^^^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:  File "/usr/lib/python3.11/site-packages/pulp_container/app/registry_api.py", line 983, in handle_safe_method
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:    repository = repository.cast()
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]:                 ^^^^^^^^^^^^^^^
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: AttributeError: 'NoneType' object has no attribute 'cast'
Jul 18 15:18:09 centos9-proxy-devel podman[8850]: 2024-07-18 15:18:08.431457537 +0000 UTC m=+0.123320772 image push bef568b8a706b75bb4dd413b108d1f74219a26d2009782cc1dd6f99cfcda9213 centos9-proxy-devel.manicotto.example.com/default_organization-precipitation-container_push_view-buttermilk_biscuits-arianna3
Jul 18 15:18:09 centos9-proxy-devel pulpcore-api[2800]: pulp [24486f0709c64d4f8c3ec0f626abcfc7]:  - - [18/Jul/2024:15:18:09 +0000] "GET /v2/default_organization-precipitation-container_push_view-buttermilk_biscuits-arianna3/blobs/sha256:cd55268b264d4d04e2eb2a95520656af57b1a2f8f8924522c71ff8b6fbdff538 HTTP/1.1" 500 145 "-" "containers/5.30.0 (github.com/containers/image)"

To Reproduce Try to GET a blob that doesn't exist from an existing repo.

Expected behavior A clear and concise description of what you expected to happen.

Additional context Tested on a Katello smart proxy. Specifically triggered trying at container push (smart proxies don't support it, but I'm trying to make sure the error messages are pretty).

lubosmj commented 1 month ago

On main: https://github.com/pulp/pulp_container/blob/7c0a2ce20b3ba36a8fe43fb60a881d8acad9ad7d/pulp_container/app/registry_api.py#L996