Hi guys—
I’m running this in AWS with an RDS mariadb instance and elasticache redis.
It seems like this instance (below) is trying to access the database and running into an error.
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
2020-09-02 16:05:57cursor, statement, parameters, context
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
2020-09-02 16:05:57cursor.execute(statement, parameters)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 170, in execute
2020-09-02 16:05:57result = self._query(query)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 328, in _query
2020-09-02 16:05:57conn.query(q)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 517, in query
2020-09-02 16:05:57self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
2020-09-02 16:05:57result.read()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 1075, in read
2020-09-02 16:05:57first_packet = self.connection._read_packet()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
2020-09-02 16:05:57packet.check_error()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
2020-09-02 16:05:57err.raise_mysql_exception(self._data)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
2020-09-02 16:05:57raise errorclass(errno, errval)
2020-09-02 16:05:57pymysql.err.InternalError: (1060, "Duplicate column name 'captain_id'")
2020-09-02 16:05:57The above exception was the direct cause of the following exception:
2020-09-02 16:05:57Traceback (most recent call last):
2020-09-02 16:05:57File "manage.py", line 9, in <module>
2020-09-02 16:05:57app = create_app()
2020-09-02 16:05:57File "/opt/CTFd/CTFd/__init__.py", line 214, in create_app
2020-09-02 16:05:57upgrade()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/flask_migrate/__init__.py", line 96, in wrapped
2020-09-02 16:05:57f(*args, **kwargs)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/flask_migrate/__init__.py", line 271, in upgrade
2020-09-02 16:05:57command.upgrade(config, revision, sql=sql, tag=tag)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/command.py", line 298, in upgrade
2020-09-02 16:05:57script.run_env()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/script/base.py", line 489, in run_env
2020-09-02 16:05:57util.load_python_file(self.dir, "env.py")
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
2020-09-02 16:05:57module = load_module_py(module_id, path)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/util/compat.py", line 184, in load_module_py
2020-09-02 16:05:57spec.loader.exec_module(module)
2020-09-02 16:05:57File "<frozen importlib._bootstrap_external>", line 728, in exec_module
2020-09-02 16:05:57File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-09-02 16:05:57File "migrations/env.py", line 96, in <module>
2020-09-02 16:05:57run_migrations_online()
2020-09-02 16:05:57File "migrations/env.py", line 90, in run_migrations_online
2020-09-02 16:05:57context.run_migrations()
2020-09-02 16:05:57File "<string>", line 8, in run_migrations
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/runtime/environment.py", line 846, in run_migrations
2020-09-02 16:05:57self.get_context().run_migrations(**kw)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/runtime/migration.py", line 520, in run_migrations
2020-09-02 16:05:57step.migration_fn(**kw)
2020-09-02 16:05:57File "/opt/CTFd/migrations/versions/b5551cd26764_add_captain_column_to_teams.py", line 27, in upgrade
2020-09-02 16:05:57op.add_column("teams", sa.Column("captain_id", sa.Integer(), nullable=True))
2020-09-02 16:05:57File "<string>", line 8, in add_column
2020-09-02 16:05:57File "<string>", line 3, in add_column
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/operations/ops.py", line 1929, in add_column
2020-09-02 16:05:57return operations.invoke(op)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/operations/base.py", line 374, in invoke
2020-09-02 16:05:57return fn(self, operation)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/operations/toimpl.py", line 132, in add_column
2020-09-02 16:05:57operations.impl.add_column(table_name, column, schema=schema, **kw)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/ddl/impl.py", line 237, in add_column
2020-09-02 16:05:57self._exec(base.AddColumn(table_name, column, schema=schema))
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/alembic/ddl/impl.py", line 140, in _exec
2020-09-02 16:05:57return conn.execute(construct, *multiparams, **params)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1020, in execute
2020-09-02 16:05:57return meth(self, multiparams, params)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 72, in _execute_on_connection
2020-09-02 16:05:57return connection._execute_ddl(self, multiparams, params)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1082, in _execute_ddl
2020-09-02 16:05:57compiled,
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1324, in _execute_context
2020-09-02 16:05:57e, statement, parameters, cursor, context
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1518, in _handle_dbapi_exception
2020-09-02 16:05:57sqlalchemy_exception, with_traceback=exc_info[2], from_=e
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
2020-09-02 16:05:57raise exception
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1284, in _execute_context
2020-09-02 16:05:57cursor, statement, parameters, context
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 590, in do_execute
2020-09-02 16:05:57cursor.execute(statement, parameters)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 170, in execute
2020-09-02 16:05:57result = self._query(query)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/cursors.py", line 328, in _query
2020-09-02 16:05:57conn.query(q)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 517, in query
2020-09-02 16:05:57self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
2020-09-02 16:05:57result.read()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 1075, in read
2020-09-02 16:05:57first_packet = self.connection._read_packet()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
2020-09-02 16:05:57packet.check_error()
2020-09-02 16:05:57File "/usr/local/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
2020-09-02 16:05:57err.raise_mysql_exception(self._data)
2020-09-02 16:05:57INFO [alembic.runtime.migration] Running upgrade 4e4d5a9ea000 -> b5551cd26764, Add captain column to Teams
2020-09-02 16:05:57INFO [alembic.runtime.migration] Context impl MySQLImpl.
2020-09-02 16:05:57INFO [alembic.runtime.migration] Will assume non-transactional DDL.
2020-09-02 16:05:53ctfd-test3.cpmrqbqmgqht.us-east-1.rds.amazonaws.com is ready
2020-09-02 16:05:53Waiting for ctfd-test3.cpmrqbqmgqht.us-east-1.rds.amazonaws.com: to be ready
When I troubleshoot on the AWS side it looks like the DB it’s using is correct but then it’s defaulting to ctfd as the user with no password… Can I get some input on this? I don’t know what changed between revisions of my container to cause this, but anything I did change shouldn’t have affected the way it’s parsing AWS ECS environment variables.