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

ContainerPushRepository.DoesNotExist exception raised when trying to push to a "regular" repo with the same name #1712

Closed
git-hyagi opened this issue Jul 24, 2024 · 0 comments · Fixed by #1727
Assignees
Labels

Comments

@git-hyagi
Copy link
Contributor

Describe the bug
Trying to push a container image with the name of a repository previously created will raise an exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/src/pulp_container/pulp_container/app/registry_api.py", line 279, in handle_exception
    response = super().handle_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/src/pulp_container/pulp_container/app/registry_api.py", line 764, in create
    _, repository = self.get_dr_push(request, path, create=True)
  File "/src/pulp_container/pulp_container/app/registry_api.py", line 373, in get_dr_push
    distribution, repository = self.create_dr(path, request)
  File "/src/pulp_container/pulp_container/app/registry_api.py", line 395, in create_dr
    repository = serializers.ContainerPushRepositorySerializer.get_or_create({"name": path})
  File "/src/pulpcore/pulpcore/app/serializers/base.py", line 383, in get_or_create
    result = cls.Meta.model.objects.get(**natural_key)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 637, in get
    raise self.model.DoesNotExist(
pulp_container.app.models.ContainerPushRepository.DoesNotExist: ContainerPushRepository matching query does not exist.
('pulp [26bd665793b340718baea475f1f2a149]: ::ffff:127.0.0.1 - admin [24/Jul/2024:17:58:25 +0000] "POST /v2/test/blobs/uploads/ HTTP/1.0" 500 145 "-" "containers/5.29.2 (github.com/containers/image)"',)

To Reproduce
Steps to reproduce the behavior:

  • create a new "regular" (non push) repository
pulp container repository create --name test
  • try to push an image with the same name as the repository:
$ podman push ce55fc75798a pulp-container:5001/test:latest
Getting image source signatures
Copying blob 20dd87a4c2ab [--------------------------------------] 8.0b / 99.0MiB | 2.0 MiB/s
...
Error: writing blob: initiating layer upload to /v2/test/blobs/uploads/ in pulp-container:5001: received unexpected HTTP status: 500 Internal Server Error

Expected behavior
Instead of raising an exception we could handle the error and provide a better output.

@lubosmj lubosmj moved this from Not Started to Todo in Pulp Container Roadmap Jul 25, 2024
@git-hyagi git-hyagi self-assigned this Aug 1, 2024
@git-hyagi git-hyagi moved this from Todo to In Progress in Pulp Container Roadmap Aug 1, 2024
git-hyagi added a commit to git-hyagi/pulp_container that referenced this issue Aug 1, 2024
git-hyagi added a commit to git-hyagi/pulp_container that referenced this issue Aug 2, 2024
git-hyagi added a commit to git-hyagi/pulp_container that referenced this issue Aug 5, 2024
git-hyagi added a commit to git-hyagi/pulp_container that referenced this issue Aug 5, 2024
git-hyagi added a commit to git-hyagi/pulp_container that referenced this issue Aug 5, 2024
git-hyagi added a commit that referenced this issue Aug 7, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Pulp Container Roadmap Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Shipped
Development

Successfully merging a pull request may close this issue.

2 participants