Description of problem: In our Ansible playbooks we are doing a four-step process for db migrations, like this: beaker-init --check (if check indicates changes are needed) beaker-init --user... --background wait for pid file to disappear beaker-init --check This works well for migrating existing databases. But for deploying a fresh environment from scratch, it will fail on the final check step. Version-Release number of selected component (if applicable): beaker-server-23.0-0.git.248.ede6acc How reproducible: easily, with a fresh environment (empty db) Steps to Reproduce: 1. Configure /etc/beaker/server.cfg to point at a new, empty database containing no tables 2. Run beaker-init --check 3. Run beaker-init --user admin --password '' --email something Actual results: Fails with an exception: Traceback (most recent call last): File "/usr/bin/beaker-init", line 9, in <module> load_entry_point('bkr.server==23.0.git.248.ede6acc', 'console_scripts', 'beaker-init')() File "/usr/lib/python2.6/site-packages/bkr/server/tools/init.py", line 378, in main return doit(opts) File "/usr/lib/python2.6/site-packages/bkr/server/util.py", line 178, in decorated return func(*args, **kwargs) File "/usr/lib/python2.6/site-packages/bkr/server/tools/init.py", line 413, in doit upgrade_db(metadata) File "/usr/lib/python2.6/site-packages/bkr/server/tools/init.py", line 265, in upgrade_db run_alembic_operation(metadata, upgrade) File "/usr/lib/python2.6/site-packages/bkr/server/tools/init.py", line 317, in run_alembic_operation env_context.run_migrations() [...] sqlalchemy.exc.NoSuchTableError: `recipe_task` Expected results: Initial beaker-init --check should report that the database needs upgrading. Subsequent beaker-init should then populate it correctly, not die with an exception. Additional info: The exception occurs because the initial beaker-init --check seems to silently create an alembic_version table (with no rows). This means the subsequent beaker-init invocation thinks the database is *not* empty and instead tries to follow the pre-0.19 inspection logic to determine the version, which then fails as above. In fact the database is just empty and should be populated from scratch. So we either need to make beaker-init ignore the presence of alembic_version when considering whether the database is empty, or we need to make beaker-init --check not silently create the alembic_version table. I would prefer the latter since beaker-init --check promises to make no changes to the database, although we are clearly violating that promise right now.
(In reply to Dan Callaghan from comment #0) > So we either need to make beaker-init ignore the presence of alembic_version > when considering whether the database is empty, or we need to make > beaker-init --check not silently create the alembic_version table. > > I would prefer the latter since beaker-init --check promises to make no > changes to the database, although we are clearly violating that promise > right now. Unfortunately the second option is not possible, as alembic itself auto-creates this table as soon as you call get_current_revision(). This is, however, fixed in newer versions of alembic, so it will be possible to remove this workaround if and when alembic is upgraded. https://gerrit.beaker-project.org/#/c/5161/
This bug fix is included in beaker-server-23.3-0.git.10.a898f12 which is currently available for download here: https://beaker-project.org/nightlies/release-23/
Beaker 23.3 has been released.