Project

Profile

Help

Issue #4575

Cannot upload file when using django runserver

Added by amacdona@redhat.com 7 months ago. Updated 6 months ago.

Status:
CLOSED - WORKSFORME
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Severity:
2. Medium
Version:
Platform Release:
Blocks Release:
OS:
Backwards Incompatible:
No
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 51

Description

[vagrant@pulp3-source-fedora28 ~]$ http --form POST localhost:8000/pulp/api/v3/artifacts/ file@~/devel/pulp_python/pulpcore-3.0.0b23-py3-none-any.whl
HTTP/1.1 500 Internal Server Error
Content-Length: 27
Content-Type: text/html
Date: Mon, 25 Mar 2019 18:42:35 GMT
Server: WSGIServer/0.2 CPython/3.6.5
Vary: Cookie
X-Frame-Options: SAMEORIGIN

<h1>Server Error (500)</h1>

pulp: django.request:ERROR: Internal Server Error: /pulp/api/v3/artifacts/
Traceback (most recent call last):
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/viewsets.py", line 116, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/mixins.py", line 19, in create
    serializer = self.get_serializer(data=request.data)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/request.py", line 212, in data
    self._load_data_and_files()
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/request.py", line 275, in _load_data_and_files
    self._data, self._files = self._parse()
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/request.py", line 350, in _parse
    parsed = parser.parse(stream, media_type, self.parser_context)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/parsers.py", line 113, in parse
    data, files = parser.parse()
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/http/multipartparser.py", line 227, in parse
    content_length, charset, content_type_extra,
  File "/home/vagrant/devel/pulpcore/pulpcore/app/files.py", line 60, in new_file
    content_type_extra)
  File "/home/vagrant/devel/pulpcore/pulpcore/app/files.py", line 16, in __init__
    super().__init__(name, content_type, size, charset, content_type_extra)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/files/uploadedfile.py", line 61, in __init__
    file = tempfile.NamedTemporaryFile(suffix='.upload' + ext, dir=settings.FILE_UPLOAD_TEMP_DIR)
  File "/usr/lib64/python3.6/tempfile.py", line 549, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/usr/lib64/python3.6/tempfile.py", line 260, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/pulp/tmp/tmp9hsz2e4m.upload.whl'


After this, I killed the django runserver and started the wsgi app via systemctl. Upload worked as expected.
[vagrant@pulp3-source-fedora28 ~]$ http --form POST localhost:8000/pulp/api/v3/artifacts/ file@~/devel/pulp_python/pulpcore-3.0.0b23-py3-none-any.whl
HTTP/1.1 201 Created
Allow: GET, POST, HEAD, OPTIONS
Connection: close
Content-Length: 694
Content-Type: application/json
Date: Mon, 25 Mar 2019 18:42:55 GMT
Location: /pulp/api/v3/artifacts/08bfeac4-fb7a-4b7b-9dbd-a1ed0ae278a5/
Server: gunicorn/19.9.0
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN

{
    "_created": "2019-03-25T18:42:55.199443Z",
    "_href": "/pulp/api/v3/artifacts/08bfeac4-fb7a-4b7b-9dbd-a1ed0ae278a5/",
    "file": "artifact/0b/50a064be9e7b20e752399486357df586bdac574fac64e62c3ca50bef449dc8",
    "md5": "9d8822eea690bd8765f5b0b01e10ca9c",
    "sha1": "da80295413a8a73ab171a2bca90896e8f5a4eb11",
    "sha224": "9baf50097129d2f48fe861904f029dabefe4117432c27a57281f4896",
    "sha256": "0b50a064be9e7b20e752399486357df586bdac574fac64e62c3ca50bef449dc8",
    "sha384": "86caad0492aa3a6829327ff2507500152cf2e5aa91a180305782ccea873242428708b0198c2c3bb9a655412245ad0991",
    "sha512": "05130b5ef51ba477393c06e5981c3778775f7a26724579de070aa00c710dcc4033c302098dc4b32c017267571ec285dedf782ed81f54234b9fa6f5cb10fac7ff",
    "size": 156352
}

History

#1 Updated by amacdona@redhat.com 7 months ago

  • Triaged changed from No to Yes
  • Sprint set to Sprint 50
  • Tags Pulp 3 added

#2 Updated by rchan 7 months ago

  • Sprint changed from Sprint 50 to Sprint 51

#3 Updated by ppicka 7 months ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to ppicka

#4 Updated by ppicka 7 months ago

I am not able to reproduce the issue, both wsgi or djang-admin run accepted rpm and whl in both ways (as put file with ./ or with ~/ path)

http --form POST localhost:8000/pulp/api/v3/artifacts/ file@*./*pulp_rpm-3.0.0b2-py3-none-any.whl
http --form POST localhost:8000/pulp/api/v3/artifacts/ file@*~/devel/*pulpcore-3.0.0rc1-py3-none-any.whl

tested with pulpcore 3.0.0rc1

#5 Updated by ppicka 6 months ago

  • Status changed from ASSIGNED to CLOSED - WORKSFORME

#6 Updated by daviddavis 6 months ago

  • Sprint/Milestone set to 3.0

#7 Updated by bmbouter 6 months ago

  • Tags deleted (Pulp 3)

Please register to edit this issue

Also available in: Atom PDF