amonapp / amon

Amon is a modern server monitoring platform.
https://docs.amon.cx
GNU Affero General Public License v3.0
1.33k stars 108 forks source link

python manage.py migrate - Error #211

Open danfoxley opened 6 years ago

danfoxley commented 6 years ago

In following steps to install on-premise, I'm stuck here. https://docs.amon.cx/onpremise/

(env) root@amon-stg:/opt/amon# python manage.py migrate Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/init.py", line 371, in execute_from_command_line utility.execute() File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/init.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, cmd_options) File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 332, in execute self.check() File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 364, in check include_deployment_checks=include_deployment_checks, File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 58, in _run_checks issues.extend(super()._run_checks(kwargs)) File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/base.py", line 351, in _run_checks return checks.run_checks(**kwargs) File "/opt/amon/env/lib/python3.5/site-packages/django/core/checks/registry.py", line 73, in run_checks new_errors = check(app_configs=app_configs) File "/opt/amon/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) File "/opt/amon/env/lib/python3.5/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces url_patterns = getattr(resolver, 'url_patterns', []) File "/opt/amon/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in get res = instance.dict[self.name] = self.func(instance) File "/opt/amon/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 536, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/opt/amon/env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in get res = instance.dict[self.name] = self.func(instance) File "/opt/amon/env/lib/python3.5/site-packages/django/urls/resolvers.py", line 529, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File "", line 969, in _find_and_load File "", line 958, in _find_and_load_unlocked File "", line 673, in _load_unlocked File "", line 665, in exec_module File "", line 222, in _call_with_frames_removed File "/opt/amon/amon/urls.py", line 8, in url(r'^api/', include('amon.apps.api.urls')), File "/opt/amon/env/lib/python3.5/site-packages/django/urls/conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File "", line 969, in _find_and_load File "", line 958, in _find_and_load_unlocked File "", line 673, in _load_unlocked File "", line 665, in exec_module File "", line 222, in _call_with_frames_removed File "/opt/amon/amon/apps/api/urls.py", line 9, in permission_classes=[])) File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/documentation.py", line 63, in include_docs_urls permission_classes=permission_classes, File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/documentation.py", line 26, in get_docs_view permission_classes=permission_classes, File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/init.py", line 41, in get_schema_view urlconf=urlconf, patterns=patterns, File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/generators.py", line 254, in init assert coreapi, 'coreapi must be installed for schema support.' AssertionError: coreapi must be installed for schema support. (env) root@amon-stg:/opt/amon# ^C

slava-vishnyakov commented 6 years ago

Yep, also having the same error.

Full gist: https://gist.github.com/slava-vishnyakov/1aa4f0a80f17282ecdc70b74fc25723b

  File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/__init__.py", line 41, in get_schema_view
    urlconf=urlconf, patterns=patterns,
  File "/opt/amon/env/lib/python3.5/site-packages/rest_framework/schemas/generators.py", line 254, in __init__
    assert coreapi, '`coreapi` must be installed for schema support.'
AssertionError: `coreapi` must be installed for schema support.
slava-vishnyakov commented 6 years ago

A little research

c555418781dbb2f3c9a23d41d3df2d17aea6ba4c is the first commit that doesn't have that error, but it has another (so this problem was probably introduced in c5207e350c63704adc69c23797fb3a1cffaff5b8):

(env) root@test1:/opt/amon# git checkout c555418781dbb2f3c9a23d41d3df2d17aea6ba4c
Previous HEAD position was c5207e3... Refactoring
HEAD is now at c555418... Cleanup
(env) root@test1:/opt/amon# python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/opt/amon/env/lib/python3.5/site-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/opt/amon/env/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/amon/env/lib/python3.5/site-packages/django/apps/registry.py", line 112, in populate
    app_config.import_models()
  File "/opt/amon/env/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/opt/amon/amon/apps/dashboards/models.py", line 10, in <module>
    from amon.apps.servers.models import server_model
  File "/opt/amon/amon/apps/servers/models.py", line 7, in <module>
    from amon.apps.devices.models import interfaces_model, volumes_model
ImportError: No module named 'amon.apps.devices'
slava-vishnyakov commented 6 years ago

The latest commit that I could install with instructions is 773fdca

git checkout 773fdca && \
pip install -r /opt/amon/requirements.txt && \
python manage.py migrate
...
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
Applying users.0001_initial... OK

(However, this version has another error deep inside: No module named amon.apps.notifications.mail.backends, possible fix: change EMAIL_BACKEND in /opt/amon/amon/settings.py to EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' and restart, doesn't work for me though, [Errno 111] Connection refused)

slava-vishnyakov commented 6 years ago

Ok, the best workaround for now that I've come up with:

# Install old working commit
cd /opt/amon && . /opt/amon/env/bin/activate && \
git checkout 773fdca && \
pip install -r /opt/amon/requirements.txt && \
python manage.py migrate

# Fix CSRF error (if you have it)
echo >> /opt/amon/amon/settings.py
echo 'CSRF_TRUSTED_ORIGINS = [host_struct.hostname,]' >> /opt/amon/amon/settings.py

# Update to master
cd /opt/amon && . /opt/amon/env/bin/activate && \
git checkout master && \
pip install -r /opt/amon/requirements.txt && \
python manage.py migrate && \
systemctl restart amon.service
danfoxley commented 6 years ago

@slava-vishnyakov Thanks for that, not sure I would have gotten there anytime soon. Along with this: https://github.com/amonapp/amon/issues/172 I was able to get an install to work.