You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/10/28 13:50:26 UTC

[GitHub] [superset] BenCh94 commented on issue #12941: Unable to Login after docker container connect to Postgres Container

BenCh94 commented on issue #12941:
URL: https://github.com/apache/superset/issues/12941#issuecomment-953864654


   I'm seeing a similar issue with a docker image deployed in AWS ECS.
   
   I have created a superset_config.py file and added it to pythonpath:
   
   ```
   # Backend metadata access
   SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URI")
   
   WEBDRIVER_BASEURL = "http://0.0.0.0:8080/"
   SUPERSET_WEBSERVER_PROTOCOL = "http"
   SUPERSET_WEBSERVER_ADDRESS = "0.0.0.0"
   SUPERSET_WEBSERVER_PORT = 8088
   
   DEBUG = True
   ```
   
   Running superset db upgrade:
   
   ```
   root@xxxxxxx:/app# superset db upgrade
   Loaded your LOCAL configuration at [/usr/local/bin/superset_config.py]
   2021-10-28 11:50:51,859:INFO:superset.utils.logging_configurator:logging was configured successfully
   2021-10-28 11:50:51,865:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
   /usr/local/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
     warnings.warn(
   INFO  [alembic.runtime.migration] Context impl **PostgresqlImpl.**
   INFO  [alembic.runtime.migration] Will assume transactional DDL.
   INFO  [alembic.runtime.migration] Running upgrade  -> 4e6a06bad7a8, Init
   INFO  [alembic.runtime.migration] Running upgrade 4e6a06bad7a8 -> 5a7bad26f2a7, empty message
   INFO  [alembic.runtime.migration] Running upgrade 5a7bad26f2a7 -> 1e2841a4128, empty message
   INFO  [alembic.runtime.migration] Running upgrade 1e2841a4128 -> 2929af7925ed, TZ offsets in data sources
   ...
   ```
   
   Followed by create-admin:
   
   ```
   root@xxxxxxxx:/app# superset fab create-admin \
                  --username admin \
                  --firstname Superset \
                  --lastname Admin \
                  --email admin@superset.com \
                  --password <xxxxxxxxxx>
   **Loaded your LOCAL configuration at [/usr/local/bin/superset_config.py]**
   2021-10-28 11:57:11,564:INFO:superset.utils.logging_configurator:logging was configured successfully
   2021-10-28 11:57:11,647:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
   /usr/local/lib/python3.8/site-packages/flask_caching/__init__.py:201: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
     warnings.warn(
   Recognized Database Authentications.
   Admin User admin created.
   ```
   and finally superset init
   
   These commands create the tables in Postgres and add the user into the ab_user table fine.
   
   But when I try to login I can see in the application logs superset is attempting to use sqlite3 and the superset_home folder has a new superset.db file created in it.
   
   ```
   2021-10-28T13:00:26.321+01:00 (sqlite3.OperationalError) no such table: ab_user
   2021-10-28T13:00:26.321+01:00 [SQL: SELECT ab_user.id AS ab_user_id, ab_user.first_name AS ab_user_first_name, ab_user.last_name AS ab_user_last_name, ab_user.username AS ab_user_username, ab_user.password AS ab_user_password, ab_user.active AS ab_user_active, ab_user.email AS ab_user_email, ab_user.last_login AS ab_user_last_login, ab_user.login_count AS ab_user_login_count, ab_user.fail_login_count AS ab_user_fail_login_count, ab_user.created_on AS ab_user_created_on, ab_user.changed_on AS ab_user_changed_on, ab_user.created_by_fk AS ab_user_created_by_fk, ab_user.changed_by_fk AS ab_user_changed_by_fk
   2021-10-28T13:00:26.322+01:00 FROM ab_user
   2021-10-28T13:00:26.322+01:00 WHERE lower(ab_user.username) = lower(?)]
   2021-10-28T13:00:26.322+01:00 [parameters: ('admin',)]
   2021-10-28T13:00:26.322+01:00 (Background on this error at: http://sqlalche.me/e/13/e3q8)
   2021-10-28T13:00:26.322+01:00 Traceback (most recent call last):
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
   2021-10-28T13:00:26.322+01:00 self.dialect.do_execute(
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
   2021-10-28T13:00:26.322+01:00 cursor.execute(statement, parameters)
   2021-10-28T13:00:26.322+01:00 sqlite3.OperationalError: no such table: ab_user
   2021-10-28T13:00:26.322+01:00 The above exception was the direct cause of the following exception:
   2021-10-28T13:00:26.322+01:00 Traceback (most recent call last):
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
   2021-10-28T13:00:26.322+01:00 rv = self.dispatch_request()
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
   2021-10-28T13:00:26.322+01:00 return self.view_functions[rule.endpoint](**req.view_args)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/views.py", line 510, in login
   2021-10-28T13:00:26.322+01:00 user = self.appbuilder.sm.auth_user_db(
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/manager.py", line 846, in auth_user_db
   2021-10-28T13:00:26.322+01:00 user = self.find_user(username=username)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/sqla/manager.py", line 159, in find_user
   2021-10-28T13:00:26.322+01:00 self.get_session.query(self.user_model)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3459, in one_or_none
   2021-10-28T13:00:26.322+01:00 ret = list(self)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
   2021-10-28T13:00:26.322+01:00 return self._execute_and_instances(context)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
   2021-10-28T13:00:26.322+01:00 result = conn.execute(querycontext.statement, self._params)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
   2021-10-28T13:00:26.322+01:00 return meth(self, multiparams, params)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
   2021-10-28T13:00:26.322+01:00 return connection._execute_clauseelement(self, multiparams, params)
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement
   2021-10-28T13:00:26.322+01:00 ret = self._execute_context(
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1316, in _execute_context
   2021-10-28T13:00:26.322+01:00 self._handle_dbapi_exception(
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception
   2021-10-28T13:00:26.322+01:00 util.raise_(
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
   2021-10-28T13:00:26.322+01:00 raise exception
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
   2021-10-28T13:00:26.322+01:00 self.dialect.do_execute(
   2021-10-28T13:00:26.322+01:00 File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute
   2021-10-28T13:00:26.322+01:00 cursor.execute(statement, parameters)
   ```
   
   @dheeraj-chaudhari is it neccessary to update the config.py manually even with the SQLALCHEMY_DATABASE_URI set in the superset_config.py file. This seems like a difficult workaround for docker container deployed in ECS.
   
   Is there anyway to force superset to use the postgres DB instead of defaulting to the sqlite db.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org