Project

Profile

Help

Issue #5125

closed

New release 3.10 of DRF has breaking changes

Added by daviddavis over 4 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 56
Quarter:

Description

The first one I saw is that detail_route was removed.

https://pypi.org/project/djangorestframework/3.10.0/

Actions #1

Updated by amacdona@redhat.com over 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to amacdona@redhat.com
  • Sprint set to Sprint 56

At a minimum, there is an import error that prevents pulplift from completing.

Actions #2

Updated by amacdona@redhat.com over 4 years ago

I've substituted `action` with `detail=True`, to fix the first problem, which shows another:


TASK [pulp-database : Create database migrations for plugins] ******************
failed: [pulp3-source-fedora28] (item=pulp-file) => {
    "ansible_loop_var": "item",
    "changed": true,
    "cmd": [
        "/usr/local/lib/pulp/bin/django-admin",
        "makemigrations",
        "file"
    ],
    "delta": "0:00:01.576581",
    "end": "2019-07-15 16:34:51.490480",
    "item": "pulp-file",
    "rc": 1,
    "start": "2019-07-15 16:34:49.913899"
}

STDERR:

Traceback (most recent call last):
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/settings.py", line 177, in import_from_string
    return import_string(val)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/vagrant/devel/pulpcore/pulpcore/app/openapigenerator.py", line 6, in <module>
    from drf_yasg.generators import OpenAPISchemaGenerator
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/drf_yasg/generators.py", line 11, in <module>
    from rest_framework.schemas.generators import SchemaGenerator, endpoint_ordering, get_pk_name
ImportError: cannot import name 'SchemaGenerator'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/pulp/bin/django-admin", line 11, in <module>
    sys.exit(execute_from_command_line())
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/management/base.py", line 361, in execute
    self.check()
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/management/base.py", line 390, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/management/base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/urls/resolvers.py", line 579, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/django/urls/resolvers.py", line 572, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/vagrant/devel/pulpcore/pulpcore/app/urls.py", line 134, in <module>
    permission_classes=(permissions.AllowAny,),
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/drf_yasg/views.py", line 68, in get_schema_view
    _generator_class = generator_class or swagger_settings.DEFAULT_GENERATOR_CLASS
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/drf_yasg/app_settings.py", line 121, in __getattr__
    val = perform_import(val, attr)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/settings.py", line 166, in perform_import
    return import_from_string(val, setting_name)
  File "/usr/local/lib/pulp/lib64/python3.6/site-packages/rest_framework/settings.py", line 180, in import_from_string
    raise ImportError(msg)
ImportError: Could not import 'pulpcore.app.openapigenerator.PulpOpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'. ImportError: cannot import name 'SchemaGenerator'.

MSG:

non-zero return code
Actions #3

Updated by amacdona@redhat.com over 4 years ago

The traceback in note-2 seems to be caused by drf-yasg which has an open issue: https://github.com/axnsan12/drf-yasg/issues/410

Added by amacdona@redhat.com over 4 years ago

Revision adeb2a7f | View on GitHub

Pin DRF to < 3.10 due to breaking changes

We cannot fix the incompatibility yet because another dependency, drf-yasg does not support drf 3.10 yet. https://github.com/axnsan12/drf-yasg/issues/410

https://pulp.plan.io/issues/5125 re #5125

Actions #4

Updated by amacdona@redhat.com over 4 years ago

Because of the drf-yasg issue, it will not be possible to fix the problems with 3.10 until e: https://github.com/axnsan12/drf-yasg/issues/410 is merged. I'm going to leave this issue open and return it to NEW.

In the meantime, I've merged https://github.com/pulp/pulpcore/pull/209/ which pins drf to < 3.10. For whoever picks this up, please remove the pin as well.

Actions #5

Updated by amacdona@redhat.com over 4 years ago

  • Status changed from ASSIGNED to NEW
  • Assignee changed from amacdona@redhat.com to bbuckingham@redhat.com
Actions #6

Updated by daviddavis over 4 years ago

  • Assignee deleted (bbuckingham@redhat.com)
Actions #7

Updated by amacdona@redhat.com over 4 years ago

  • Triaged changed from No to Yes
Actions #8

Updated by amacdona@redhat.com over 4 years ago

drf-yasg has been updated, this is now unblocked.

Actions #9

Updated by CodeHeeler over 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to CodeHeeler
Actions #10

Updated by CodeHeeler over 4 years ago

  • Status changed from ASSIGNED to POST

PRs at this stage:

https://github.com/pulp/pulpcore/pull/213

https://github.com/pulp/pulp_file/pull/263

Currently blocked awaiting drf-yasg 1.16.2 fixing another blocker

Actions #11

Updated by CodeHeeler over 4 years ago

Travis test failing:
https://travis-ci.com/pulp/pulpcore/jobs/219254034

Getting a 500 error when hitting pulp/api/v3/docs/api.json?plugin=pulpcore

Traceback:


-- Logs begin at Wed 2019-07-24 21:03:17 UTC. --
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:   File "/home/vagrant/devel/pulpcore/pulpcore/app/openapigenerator.py", line 258, in get_operation
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:     if 'file' in [param['type'] for param in self.get_request_body_parameters(multipart)]:
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:   File "/usr/local/lib/pulp/lib64/python3.6/site-packages/drf_yasg/inspectors/view.py", line 71, in get_request_body_parameters
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:     serializer = self.get_request_serializer()
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:   File "/usr/local/lib/pulp/lib64/python3.6/site-packages/drf_yasg/inspectors/view.py", line 118, in get_request_serializer
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:     body_override = self._get_request_body_override()
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:   File "/usr/local/lib/pulp/lib64/python3.6/site-packages/drf_yasg/inspectors/view.py", line 105, in _get_request_body_override
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]:     "); are you looking for query_serializer or manual_parameters?")
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]: drf_yasg.errors.SwaggerGenerationError: request_body can only be applied to (PUT,PATCH,POST,DELETE); are you looking for query_serializer or manual_parameters?
Jul 24 21:24:20 pulp3-source-fedora28.localhost.example.com gunicorn[27696]: 127.0.0.1 - admin [24/Jul/2019:21:24:20 +0000] "GET /pulp/api/v3/docs/api.json?plugin=pulpcore HTTP/1.1" 500 27 "-" "HTTPie/0.9.4"
Actions #12

Updated by dkliban@redhat.com over 4 years ago

That traceback is saying that Pulp should not call get_request_body_parameters() when generating OpenAPI schema for GET operations. Pulp should check the type of the operation before trying to call get_request_body_parameters() on line 258 of pulpcore/pulpcore/app/openapigenerator.py.

Added by CodeHeeler over 4 years ago

Revision 249323e2 | View on GitHub

Fix breaking changes from DRF 3.10

Django restframework 3.10.0 has introduced breaking changes Unpinning DRF now that a drf-yasg blocker has been fixed

Required PR: https://github.com/pulp/pulp_file/pull/263

fixes #5125 https://pulp.plan.io/issues/5125

Actions #13

Updated by CodeHeeler over 4 years ago

  • Status changed from POST to MODIFIED
Actions #14

Updated by CodeHeeler over 4 years ago

  • Status changed from MODIFIED to POST

Added by CodeHeeler over 4 years ago

Revision 383d12a4 | View on GitHub

Fix breaking changes from DRF 3.10

DRF 3.10.0 introduced breaking changes. Namely, @detail_route decorator is replaced by @action(detail=True)

fixes #5125 https://pulp.plan.io/issues/5125

Actions #15

Updated by CodeHeeler over 4 years ago

  • Status changed from POST to MODIFIED
Actions #16

Updated by bmbouter over 4 years ago

  • Sprint/Milestone set to 3.0.0
Actions #17

Updated by bmbouter over 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF