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

Plugin Load Failure #95

Closed
pke11y opened this issue Mar 5, 2021 · 7 comments · Fixed by #140
Closed

Plugin Load Failure #95

pke11y opened this issue Mar 5, 2021 · 7 comments · Fixed by #140
Assignees
Labels
type: bug Something isn't working as expected
Milestone

Comments

@pke11y
Copy link
Contributor

pke11y commented Mar 5, 2021

Environment

  • Python version: 3.8.5
  • Nautobot version: 1.0.0b1

Steps to Reproduce

  1. pip install nautobot-netbox-importer
  2. Enable the plugin in nautobot_config.py:
    PLUGINS = ["nautobot_netbox_importer"]
  3. sudo systemctl restart nautobot
  4. Browse to the nautobot web User Interface

Expected Behavior

Expected to see the nautobot landing page on the UI

Observed Behavior

Internal Server Error displayed on UI

Gunicorn reports errors in the nautobot logs.

(nautobot) nautobot@ubuntu-20-04:~$ sudo journalctl -eu nautobot.service
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     response = self.get_response(request)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/core/handlers/base.py", line 130, in get_response
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     response = self._middleware_chain(request)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/core/handlers/exception.py", line 49, in inner
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     response = response_for_exception(request, exc)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/core/handlers/exception.py", line 103, in response_for_exception
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/core/handlers/exception.py", line 141, in handle_uncaught_exception
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     callback, param_dict = resolver.resolve_error_handler(500)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/urls/resolvers.py", line 602, in resolve_error_handler
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     res = instance.__dict__[self.name] = self.func(instance)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/urls/resolvers.py", line 582, in urlconf_module
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     return import_module(self.urlconf_name)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     return _bootstrap._gcd_import(name[level:], package, level)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/nautobot/core/urls.py", line 12, in <module>
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     from nautobot.extras.plugins.urls import (
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/nautobot/extras/plugins/urls.py", line 32, in <module>
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     app = apps.get_app_config(plugin_name)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:   File "/opt/nautobot/lib/python3.8/site-packages/django/apps/registry.py", line 163, in get_app_config
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]:     raise LookupError(message)
Mar 05 11:52:52 ubuntu-20-04 gunicorn[25549]: LookupError: No installed app with label 'nautobot_netbox_importer'.
@pke11y
Copy link
Contributor Author

pke11y commented Mar 5, 2021

Also tried with plugin nautobot-device-onboarding. Same result.

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Mar 5, 2021
@glennmatthews glennmatthews added this to the v1.0.0 milestone Mar 5, 2021
@jathanism jathanism self-assigned this Mar 5, 2021
@jathanism
Copy link
Contributor

Just for some context, was troubleshooting this last night with @jvanderaa and we isolated it to be directly related to Gunicorn for "some" reason.

@jathanism
Copy link
Contributor

Mirroring the comment here from #88 for those with vested interest:

This addresses the issue with #95 by circumventing it entirely, but it does not fix the underlying issue with WHY the plugins are not being loaded correctly. That will take more time, but this will alleviate the problem for the near term by launching uWSGI from within the server utility instead of the other way around, with Gunicorn/uWSGI invoking the application.

@jathanism
Copy link
Contributor

@pke11y I still intend to track this to get to the bottom of this issue, but can you please give v1.0.0b2 a shot w/ the revised install instructions to use uWSGI over Gunicorn and let me know how it goes for you? Thanks!

@pke11y
Copy link
Contributor Author

pke11y commented Mar 10, 2021

@jathanism no probs. Will try it this evening.

@pke11y
Copy link
Contributor Author

pke11y commented Mar 11, 2021

@jathanism tried b2 version w/ uWSGI and loaded the nautobot_netbox_importer. Install went well and plugin loaded. Nice job!

@jathanism
Copy link
Contributor

@pke11y Great, thanks! That means we've successfully worked around this issue for now while creating new ones. :)

jathanism added a commit to jathanism/nautobot that referenced this issue Mar 13, 2021
This updates `nautobot.extras.plugins.utils.load_plugins` to only update
or extend `INSTALLED_APPS` and `MIDDLEWARE` if the plugins in question
haven't already been applied.

In my testing this appears to have alleviated the bug in plugins not
being correctly loaded within the WSGI application for both Gunicorn and
uWSGI.
jathanism added a commit that referenced this issue Mar 15, 2021
This updates `nautobot.extras.plugins.utils.load_plugins` to only update
or extend `INSTALLED_APPS` and `MIDDLEWARE` if the plugins in question
haven't already been applied.

In my testing this appears to have alleviated the bug in plugins not
being correctly loaded within the WSGI application for both Gunicorn and
uWSGI.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants