keitaroinc / docker-ckan

CKAN docker images, docker-compose and examples
Apache License 2.0
72 stars 51 forks source link

[BUG] Password authentication failed for user "datastore_ro" #53

Closed miqbal23 closed 3 years ago

miqbal23 commented 3 years ago

Describe the bug I'm trying to test deploying CKAN using docker based on this article. But after executing docker-compose up --build, the ckan container exited. Further opening the logs showed there's issue in running the 00_create_datastore.sh script on db.

After doing a bit digging, it seems this is also an ongoing issue on https://github.com/ckan/ckan/issues/5321

Docker images affected CKAN 2.9.1

Expected behaviour CKAN should be running as described in the article, by accessing http;//localhost:5000/

Logs Logs from ckan container

ckan          | [prerun] Unable to connect to the database...try again in a while.
ckan          | [prerun] Start check_db_connection...
ckan          | [prerun] Start check_solr_connection...
ckan          | [prerun] Start init_db...
ckan          | [prerun] Initializing or upgrading db - start using ckan db init
ckan          | 2021-07-11 11:02:47,836 INFO  [ckan.cli] Using configuration file /srv/app/production.ini
ckan          | 2021-07-11 11:02:47,836 INFO  [ckan.config.environment] Loading static files from public
ckan          | 2021-07-11 11:02:47,904 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
ckan          | 2021-07-11 11:02:48,466 INFO  [ckan.config.environment] Loading templates from /srv/app/src/ckan/ckan/templates
ckan          | Traceback (most recent call last):
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
ckan          |     return fn()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 303, in unique_connection
ckan          |     return _ConnectionFairy._checkout(self)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 760, in _checkout
ckan          |     fairy = _ConnectionRecord.checkout(pool)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 492, in checkout
ckan          |     rec = pool._do_get()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
ckan          |     self._dec_overflow()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
ckan          |     compat.reraise(exc_type, exc_value, exc_tb)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 154, in reraise
ckan          |     raise value
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
ckan          |     return self._create_connection()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
ckan          |     return _ConnectionRecord(self)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 437, in __init__
ckan          |     self.__connect(first_connect_check=True)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 639, in __connect
ckan          |     connection = pool._invoke_creator(self)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
ckan          |     return dialect.connect(*cargs, **cparams)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 451, in connect
ckan          |     return self.dbapi.connect(*cargs, **cparams)
ckan          |   File "/usr/lib/python3.8/site-packages/psycopg2/__init__.py", line 126, in connect
ckan          |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
ckan          | psycopg2.OperationalError: FATAL:  password authentication failed for user "datastore_ro"
ckan          |
ckan          |
ckan          | The above exception was the direct cause of the following exception:
ckan          |
ckan          | Traceback (most recent call last):
ckan          |   File "/usr/bin/ckan", line 33, in <module>
ckan          |     sys.exit(load_entry_point('ckan', 'console_scripts', 'ckan')())
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 722, in __call__
ckan          |     return self.main(*args, **kwargs)
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 696, in main
ckan          |     with self.make_context(prog_name, args, **extra) as ctx:
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 621, in make_context
ckan          |     self.parse_args(ctx, args)
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 1018, in parse_args
ckan          |     rest = Command.parse_args(self, ctx, args)
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 880, in parse_args
ckan          |     value, args = param.handle_parse_result(ctx, opts, args)
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 1403, in handle_parse_result
ckan          |     value = invoke_param_callback(
ckan          |   File "/usr/lib/python3.8/site-packages/click/core.py", line 78, in invoke_param_callback
ckan          |     return callback(ctx, param, value)
ckan          |   File "/srv/app/src/ckan/ckan/cli/cli.py", line 102, in _init_ckan_config
ckan          |     ctx.obj = CkanCommand(value)
ckan          |   File "/srv/app/src/ckan/ckan/cli/cli.py", line 52, in __init__
ckan          |     self.app = make_app(self.config)
ckan          |   File "/srv/app/src/ckan/ckan/config/middleware/__init__.py", line 56, in make_app
ckan          |     load_environment(conf)
ckan          |   File "/srv/app/src/ckan/ckan/config/environment.py", line 123, in load_environment
ckan          |     p.load_all()
ckan          |   File "/srv/app/src/ckan/ckan/plugins/core.py", line 140, in load_all
ckan          |     load(*plugins)
ckan          |   File "/srv/app/src/ckan/ckan/plugins/core.py", line 168, in load
ckan          |     plugins_update()
ckan          |   File "/srv/app/src/ckan/ckan/plugins/core.py", line 122, in plugins_update
ckan          |     environment.update_config()
ckan          |   File "/srv/app/src/ckan/ckan/config/environment.py", line 309, in update_config
ckan          |     plugin.configure(config)
ckan          |   File "/srv/app/src/ckan/ckanext/datastore/plugin.py", line 82, in configure
ckan          |     self.backend.configure(config)
ckan          |   File "/srv/app/src/ckan/ckanext/datastore/backend/postgres.py", line 1726, in configure
ckan          |     self.read_engine = self._get_read_engine()
ckan          |   File "/srv/app/src/ckan/ckanext/datastore/backend/postgres.py", line 1624, in _get_read_engine
ckan          |     return _get_engine_from_url(self.read_url)
ckan          |   File "/srv/app/src/ckan/ckanext/datastore/backend/postgres.py", line 127, in _get_engine_from_url
ckan          |     register_default_json(conn_or_curs=engine.raw_connection().connection,
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2292, in raw_connection
ckan          |     return self._wrap_pool_connect(
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2265, in _wrap_pool_connect
ckan          |     Connection._handle_dbapi_exception_noconnection(
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
ckan          |     util.raise_from_cause(sqlalchemy_exception, exc_info)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 399, in raise_from_cause
ckan          |     reraise(type(exception), exception, tb=exc_tb, cause=cause)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
ckan          |     raise value.with_traceback(tb)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
ckan          |     return fn()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 303, in unique_connection
ckan          |     return _ConnectionFairy._checkout(self)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 760, in _checkout
ckan          |     fairy = _ConnectionRecord.checkout(pool)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 492, in checkout
ckan          |     rec = pool._do_get()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 139, in _do_get
ckan          |     self._dec_overflow()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
ckan          |     compat.reraise(exc_type, exc_value, exc_tb)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 154, in reraise
ckan          |     raise value
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 136, in _do_get
ckan          |     return self._create_connection()
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
ckan          |     return _ConnectionRecord(self)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 437, in __init__
ckan          |     self.__connect(first_connect_check=True)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 639, in __connect
ckan          |     connection = pool._invoke_creator(self)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
ckan          |     return dialect.connect(*cargs, **cparams)
ckan          |   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 451, in connect
ckan          |     return self.dbapi.connect(*cargs, **cparams)
ckan          |   File "/usr/lib/python3.8/site-packages/psycopg2/__init__.py", line 126, in connect
ckan          |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
ckan          | sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL:  password authentication failed for user "datastore_ro"
ckan          |
ckan          | (Background on this error at: http://sqlalche.me/e/e3q8)
ckan          |
ckan          | [prerun] Database not ready, waiting a bit before exit...
ckan          | [CKAN prerun] FAILED. Exiting...

Logs from db container

db            | 2021-07-11 11:02:34.603 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db            | 2021-07-11 11:02:34.603 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db            | 2021-07-11 11:02:34.914 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db            | 2021-07-11 11:02:35.260 UTC [25] LOG:  database system was interrupted; last known up at 2021-07-11 10:54:47 UTC
db            | 2021-07-11 11:02:35.261 UTC [26] FATAL:  the database system is starting up
db            | 2021-07-11 11:02:37.638 UTC [25] LOG:  database system was not properly shut down; automatic recovery in progress
db            | 2021-07-11 11:02:37.748 UTC [25] LOG:  redo starts at 0/16532D0
db            | 2021-07-11 11:02:37.748 UTC [25] LOG:  invalid record length at 0/16533C0: wanted 24, got 0
db            | 2021-07-11 11:02:37.748 UTC [25] LOG:  redo done at 0/1653378
db            | 2021-07-11 11:02:37.748 UTC [25] LOG:  last completed transaction was at log time 2021-07-11 10:54:47.915091+00
db            | 2021-07-11 11:02:38.534 UTC [1] LOG:  database system is ready to accept connections
db            | 2021-07-11 11:02:48.077 UTC [34] ERROR:  relation "user" does not exist at character 515
db            | 2021-07-11 11:02:48.077 UTC [34] STATEMENT:  SELECT "user".password AS user_password, "user".id AS user_id, "user".name AS user_name, "user".fullname AS user_fullname, "user".email AS user_email, "user".apikey AS user_apikey, "user".created AS user_created, "user".reset_key AS user_reset_key, "user".about AS user_about, "user".activity_streams_email_notifications AS user_activity_streams_email_notifications, "user".sysadmin AS user_sysadmin, "user".state AS user_state, "user".image_url AS user_image_url, "user".plugin_extras AS user_plugin_extras
db            |         FROM "user"
db            |         WHERE "user".name = 'default' OR "user".id = 'default' ORDER BY "user".name
db            |          LIMIT 1
db            | 2021-07-11 11:02:48.483 UTC [36] FATAL:  password authentication failed for user "datastore_ro"
db            | 2021-07-11 11:02:48.483 UTC [36] DETAIL:  Role "datastore_ro" does not exist.
db            |         Connection matched pg_hba.conf line 95: "host all all all md5"
mbocevski commented 3 years ago

Have you tried running this with the latest patch version of 2.9? 2.9.3?

mbocevski commented 3 years ago

Closing due to inactivity