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

Fix bug 1704038: Upgrade to Django 3.2 #1921

Merged
merged 3 commits into from
Apr 16, 2021
Merged

Conversation

PFischbeck
Copy link
Collaborator

This upgrades Pontoon to Django 3.2, which means we should be good to go until April 2024 😄

App configs are now automatically discovered, and most of our current app configs were redundant or had wrong names.
The DEFAULT_AUTO_FIELD is needed to prevent unwanted migrations in the future, when the default value will change to BigAutoField.

I'll submit a small additional PR to make use of the new @admin.display decorator.

@PFischbeck
Copy link
Collaborator Author

I don't understand the CI Docker build failure, locally I can build the Docker container just fine. In particular, collectstatic doesn't fail for me.

@Pike
Copy link
Collaborator

Pike commented Apr 14, 2021

I can reproduce locally, and for me it seems that

https://github.com/PFischbeck/pontoon/blob/django-3.2/pontoon/tags/__init__.py#L1

is the culprit.

App configs are now automatically discovered, and most of our current app configs were redundant or had wrong names.
The DEFAULT_AUTO_FIELD is needed to prevent unwanted migrations in the future, when the default value will change to BigAutoField.
@mathjazz
Copy link
Collaborator

Thanks for the patch!

I've deployed to stage and noticed /projects is failing:

Traceback (most recent call last):
    content = loader.render_to_string(template_name, context, request, using=using)
    raise value.with_traceback(tb)
  File "/app/pontoon/projects/templates/projects/projects.html", line 52, in block "heading"
    {{ HeadingInfo.progress_chart_legend(projects.get_stats_sum()) }}
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 49, in inner
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception
  File "/app/.heroku/python/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 490, in wrapper
  File "/app/.heroku/python/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 626, in wrapper
TypeError: cannot unpack non-iterable function object
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = response or self.get_response(request)
  File "/app/.heroku/python/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 1203, in _wrapper
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 49, in inner
    response = response_for_exception(request, exc)
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
    return _wrapped(*args, **kwargs)
    return wrapped(request, resolver, exc_info)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 152, in handle_uncaught_exception
    callback = resolver.resolve_error_handler(500)

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/deprecation.py", line 117, in __call__
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/app/.heroku/python/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 490, in wrapper
    return wrapped(request, resolver, exc_info)
    callback = resolver.resolve_error_handler(500)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
    return wrapped(*args, **kwargs)
    callback = resolver.resolve_error_handler(500)
  File "/app/.heroku/python/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 626, in wrapper
TypeError: cannot unpack non-iterable function object

Traceback (most recent call last):
    response = response or self.get_response(request)
    callback, param_dict = wrapped(*args, **kwargs)
    response = get_response(request)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/deprecation.py", line 117, in __call__
    response = response_for_exception(request, exc)
    return wrapped(request, resolver, exc_info)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/handlers/exception.py", line 152, in handle_uncaught_exception
  File "/app/.heroku/python/lib/python3.8/site-packages/newrelic/hooks/framework_django.py", line 626, in wrapper
    callback, param_dict = wrapped(*args, **kwargs)
TypeError: cannot unpack non-iterable function object

@Pike
Copy link
Collaborator

Pike commented Apr 15, 2021

I bet this is an old newrelic bug, we're a few years behind on updates there.

@PFischbeck
Copy link
Collaborator Author

Turns out this does come from the Django update, and is caused by our own code:

Instantiating an abstract model now raises TypeError.

We instantiate the abstract model AggregatedStats. I'll add a regression test and fix it. Maybe there's also a follow-up bug in newrelic when handling/passing on the root cause.

Django 3.2 throws an error when instantiating an abstract model.
This commit also adds tests for the views that were previously not covered.
@PFischbeck
Copy link
Collaborator Author

@mathjazz I've pushed a fix, the same error also happened for teams/. It's now covered by tests and should hopefully work in staging.

(I also did some drive-by improvement of test fixture usage in projects/tests/test_views.py)

Copy link
Collaborator

@Pike Pike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, just one more thing about test coverage (or the claim of it).

pontoon/projects/tests/test_views.py Show resolved Hide resolved
pontoon/teams/tests/test_views.py Show resolved Hide resolved
Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on stage.

Nice work!

@mathjazz mathjazz merged commit efcd443 into mozilla:master Apr 16, 2021
@PFischbeck PFischbeck deleted the django-3.2 branch April 17, 2021 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants