Skip to content

Instantly share code, notes, and snippets.

@elmiko
Created April 6, 2015 23:01
Show Gist options
  • Save elmiko/34c2f064c104d08a3e1f to your computer and use it in GitHub Desktop.
Save elmiko/34c2f064c104d08a3e1f to your computer and use it in GitHub Desktop.
Barbican Juno -> Kilo migration test

testing barbican migration from stable/juno to kilo

this is the notes produced from attempting to run a database migration on a stable/juno barbican to the current master.

setup

mariadb server running on localhost barbican database configured for barbican user (pw: openstack)

steps

  • checkout upstream stable/juno
  • start new virtualenv
  • barbican.sh install
  • create a secret as per quick start guide
  • retrieve secrets
  • stop barbican with Ctrl-C
  • checkout master
  • pip install -r requirements.txt
  • python setup.py install
  • barbican-db-manage.py --dburl "mysql://barbican:openstack@localhost/barbican" upgrade

output from barbican-db-manage.py:

2015-04-06 18:54:24.941 797 ERROR __main__ [-] Problem trying to execute Alembic commands
2015-04-06 18:54:24.941 797 TRACE __main__ Traceback (most recent call last):
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/bin/barbican-db-manage.py", line 135, in main
2015-04-06 18:54:24.941 797 TRACE __main__     dm.execute()
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/bin/barbican-db-manage.py", line 117, in execute
2015-04-06 18:54:24.941 797 TRACE __main__     args.func(args)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/bin/barbican-db-manage.py", line 99, in upgrade
2015-04-06 18:54:24.941 797 TRACE __main__     commands.upgrade(to_version=args.version, sql_url=args.dburl)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/workspace/openstack/barbican/barbican/model/migration/commands.py", line 67, in upgrade
2015-04-06 18:54:24.941 797 TRACE __main__     alembic_command.upgrade(alembic_cfg, to_version)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/command.py", line 165, in upgrade
2015-04-06 18:54:24.941 797 TRACE __main__     script.run_env()
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/script.py", line 390, in run_env
2015-04-06 18:54:24.941 797 TRACE __main__     util.load_python_file(self.dir, 'env.py')
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/util.py", line 243, in load_python_file
2015-04-06 18:54:24.941 797 TRACE __main__     module = load_module_py(module_id, path)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/compat.py", line 79, in load_module_py
2015-04-06 18:54:24.941 797 TRACE __main__     mod = imp.load_source(module_id, path, fp)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/workspace/openstack/barbican/barbican/model/migration/alembic_migrations/env.py", line 100, in <module>
2015-04-06 18:54:24.941 797 TRACE __main__     run_migrations_online()
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/workspace/openstack/barbican/barbican/model/migration/alembic_migrations/env.py", line 91, in run_migrations_online
2015-04-06 18:54:24.941 797 TRACE __main__     context.run_migrations()
2015-04-06 18:54:24.941 797 TRACE __main__   File "<string>", line 7, in run_migrations
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/environment.py", line 742, in run_migrations
2015-04-06 18:54:24.941 797 TRACE __main__     self.get_context().run_migrations(**kw)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/migration.py", line 309, in run_migrations
2015-04-06 18:54:24.941 797 TRACE __main__     step.migration_fn(**kw)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/workspace/openstack/barbican/barbican/model/migration/alembic_migrations/versions/13d127569afa_create_secret_store_metadata_table.py", line 49, in upgrade
2015-04-06 18:54:24.941 797 TRACE __main__     sa.PrimaryKeyConstraint('id'),
2015-04-06 18:54:24.941 797 TRACE __main__   File "<string>", line 7, in create_table
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/operations.py", line 936, in create_table
2015-04-06 18:54:24.941 797 TRACE __main__     self.impl.create_table(table)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/ddl/impl.py", line 181, in create_table
2015-04-06 18:54:24.941 797 TRACE __main__     self._exec(schema.CreateTable(table))
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/alembic/ddl/impl.py", line 105, in _exec
2015-04-06 18:54:24.941 797 TRACE __main__     return conn.execute(construct, *multiparams, **params)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 841, in execute
2015-04-06 18:54:24.941 797 TRACE __main__     return meth(self, multiparams, params)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 69, in _execute_on_connection
2015-04-06 18:54:24.941 797 TRACE __main__     return connection._execute_ddl(self, multiparams, params)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 895, in _execute_ddl
2015-04-06 18:54:24.941 797 TRACE __main__     compiled
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1070, in _execute_context
2015-04-06 18:54:24.941 797 TRACE __main__     context)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1271, in _handle_dbapi_exception
2015-04-06 18:54:24.941 797 TRACE __main__     exc_info
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
2015-04-06 18:54:24.941 797 TRACE __main__     reraise(type(exception), exception, tb=exc_tb)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1063, in _execute_context
2015-04-06 18:54:24.941 797 TRACE __main__     context)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute
2015-04-06 18:54:24.941 797 TRACE __main__     cursor.execute(statement, parameters)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
2015-04-06 18:54:24.941 797 TRACE __main__     self.errorhandler(self, exc, value)
2015-04-06 18:54:24.941 797 TRACE __main__   File "/home/mike/.venvs/barb-db/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2015-04-06 18:54:24.941 797 TRACE __main__     raise errorclass, errorvalue
2015-04-06 18:54:24.941 797 TRACE __main__ OperationalError: (OperationalError) (1005, 'Can\'t create table `barbican`.`secret_store_metadata` (errno: 150 "Foreign key constraint is incorrectly formed")') '\nCREATE TABLE secret_store_metadata (\n\tid VARCHAR(36) NOT NULL, \n\tcreated_at DATETIME NOT NULL, \n\tupdated_at DATETIME NOT NULL, \n\tdeleted_at DATETIME, \n\tdeleted BOOL NOT NULL, \n\tstatus VARCHAR(20) NOT NULL, \n\tsecret_id VARCHAR(36) NOT NULL, \n\t`key` VARCHAR(255) NOT NULL, \n\tvalue VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(secret_id) REFERENCES secrets (id), \n\tCHECK (deleted IN (0, 1))\n)\n\n' ()
2015-04-06 18:54:24.941 797 TRACE __main__ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment