no such table: auth_user

Asked by Simon Trimboy on 2020-09-15

Have upgraded to 1.1.7 but am unable to see the UIs - composer or dashboard

Debug is on. Stack trace from composer is pasted below. The dashboard just displays "Drop To Merge"

Running:-

 - python 3.8.5 in /usr/local/ prefix
 - sqlite 3.33.0
 - mod_wsgi 4.7.1

I have run following django commands

PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py migrate --noinput --settings=graphite.local_settings
Operations to perform:
  Apply all migrations: (none)
Running migrations:
  No migrations to apply.

Stack Trace from composer :-

Environment:

Request Method: GET
Request URL: http://xxxxxx.com/composer

Django Version: 3.0.10
Python Version: 3.8.5
Installed Applications:
('graphite.account',
 'graphite.browser',
 'graphite.composer',
 'graphite.dashboard',
 'graphite.events',
 'graphite.functions',
 'graphite.metrics',
 'graphite.render',
 'graphite.tags',
 'graphite.url_shortener',
 'graphite.whitelist',
 'django.contrib.auth',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'tagging')
Installed Middleware:
('graphite.middleware.LogExceptionsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 396, in execute
    return Database.Cursor.execute(self, query, params)

The above exception (no such table: auth_user) was the direct cause of the following exception:
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/graphite/webapp/graphite/composer/views.py", line 27, in composer
    profile = getProfile(request)
  File "/opt/graphite/webapp/graphite/user_util.py", line 35, in getProfile
    return default_profile()
  File "/opt/graphite/webapp/graphite/user_util.py", line 49, in default_profile
    user, created = User.objects.get_or_create(
  File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 559, in get_or_create
    return self.get(**kwargs), False
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 411, in get
    num = len(clone)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 258, in __len__
    self._fetch_all()
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 1261, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 57, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1154, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 396, in execute
    return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /composer
Exception Value: no such table: auth_user

Does anyone have any ideas what I can look at next to resolve ?

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Denis Zhdanov
Solved:
Last query:
Last reply:
Revision history for this message
Denis Zhdanov (deniszhdanov) said :
#1

Hello Simon,

Try to run first
PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py makemigrations --settings=graphite.local_settings
then
PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py migrate --settings=graphite.local_settings

WBR,
   Denys

Revision history for this message
Simon Trimboy (simontrimboy) said :
#2

Hi,

Unfortunately this didn't seem to generate any db tables either. What would one expect from running the below commands in a fresh install ?

PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py makemigrations --settings=graphite.local_settings
No changes detected

[root@sm-metric-store-0 graphite]# PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py migrate --settings=graphite.local_settings
Operations to perform:
  Apply all migrations: (none)
Running migrations:
  No migrations to apply.

I have run the inspectdb command below :

PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py inspectdb --settings=graphite.local_settings
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models

class DjangoMigrations(models.Model):
    app = models.CharField(max_length=255)
    name = models.CharField(max_length=255)
    applied = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'django_migrations'

Revision history for this message
Denis Zhdanov (deniszhdanov) said :
#3

Fresh install these should work out of the box:

export PYTHONPATH=/opt/graphite/webapp
export DJANGO_SETTINGS_MODULE=graphite.settings
/usr/local/bin/django-admin.py makemigrations
/usr/local/bin/django-admin.py migrate auth
/usr/local/bin/django-admin.py migrate --run-syncdb

Revision history for this message
Simon Trimboy (simontrimboy) said :
#4

/usr/local/bin/django-admin.py makemigrations
/opt/graphite/webapp/graphite/settings.py:348: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security
  warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
SystemCheckError: System check identified some issues:

ERRORS:
?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting.

Revision history for this message
Denis Zhdanov (deniszhdanov) said :
#5

Try to configure STATIC_ROOT explicitly, e.g. STATIC_ROOT = '/opt/graphite/static'

Revision history for this message
Simon Trimboy (simontrimboy) said :
#6

I don't have a /opt/graphite/static directory I am using the default.

This I understand to be :-

/opt/graphite/webapp/content/

Is this correct becuase your docs also mostly refer to /opt/graphite/static in the configuring the webapp section ?

Revision history for this message
Best Denis Zhdanov (deniszhdanov) said :
#7

No, it should be separate directory, and you need to run `django-admin.py collectstatic` to copy files there, and set up webserver to serve static files (or install whitenoise python module, but that's less performant)

Revision history for this message
Simon Trimboy (simontrimboy) said :
#8

Thanks Denis Zhdanov, that solved my question.

Revision history for this message
Simon Trimboy (simontrimboy) said :
#9

Further to deploying the static content I used the example apache wsgi conf from the docs here : https://graphite.readthedocs.io/en/latest/config-webapp.html#apache-mod-wsgi

As I am using python3.8 under non-system prefix /usr/local I also made use of the WSGIPythonHome directive :

<IfModule mod_wsgi.c>
  WSGIPythonHome /usr/local/
  WSGISocketPrefix /var/run/wsgi
</IfModule>

Thanks for your assistance.