sahara-api should not create DB from metadata

Bug #1300190 reported by Dmitry Mescheryakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sahara
Fix Released
Critical
Sergey Lukjanov

Bug Description

Right now we create DB tables on sahara-api start:
https://github.com/openstack/sahara/blob/master/sahara/cli/sahara_api.py#L61

We do this by creating tables from metadata. That is not right because we support alembic migrations. With alembic tables could be created with:
sahara-db-manage upgrade head

Comparing these two ways the second one is superior. Creating tables from metadata works _only_ by creating new tables from scratch. Alembic supports not just DB creation, but migrations as well out of the box. I.e. when a new Sahara project releases, user will just run the same 'sahara-db-manage upgrade head', and his DB will be migrated to a new version preserving all the data.

There is no sense in keeping tables creation from metadata, since alembic already does that. But also we should not run alembic migrations automatically on start. Managing DB is a serious task and should be performed by person, and not implicitly by server itself. For instance, a person might decide to take a backup before proceeding with upgrade.

Revision history for this message
Sergey Lukjanov (slukjanov) wrote :

So, some additional notes:

* it'll remove implicit db management;
* it was already approved https://review.openstack.org/#/c/68631/2/savanna/main.py but it's missing one more place where db auto-created, so, it means that overall approach was applied and approved months ago, but it's a bug in this approach.

Changed in sahara:
milestone: none → icehouse-rc1
assignee: nobody → Sergey Lukjanov (slukjanov)
status: New → Triaged
importance: Undecided → Critical
Changed in sahara:
status: Triaged → In Progress
Revision history for this message
Matthew Farrellee (mattf) wrote :

please justify the urgency for making this change so close to the release date.

for instance, what happens if we do not get this into icehouse?

Revision history for this message
Dmitry Mescheryakov (dmitrymex) wrote :

For the record, we discussed that in the chat. The main driver in fixing this right now is that if a user create database from metadata, he will not be able to migrate from Icehouse to Juno. Only databases created by alembic could be migrated to the later version.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to sahara (master)

Reviewed: https://review.openstack.org/82750
Committed: https://git.openstack.org/cgit/openstack/sahara/commit/?id=c7a009805e43a639f2292f6878351580e64cdead
Submitter: Jenkins
Branch: master

commit c7a009805e43a639f2292f6878351580e64cdead
Author: Sergey Lukjanov <email address hidden>
Date: Tue Mar 25 13:28:26 2014 +0400

    Fix db management: don't autocreate db on start

    We should use sahara-db-manage for db creation instead of auto created
    db schema from metadata. This approach was applied by adding support for
    alembic-based migrations and db autocreation code was removed in
    I14a0602bb34bf09086428766cb681345191436fe, but it one more place where
    we're autocreating db was missed, so, it's a fix for this issue.

    Additionally, cleanup custom hacking check for sahara.db calls.
    Docs already contains notes about need for using sahara-db-manage for
    database creation.

    Note: The main driver in fixing this right now is that if a user create
    database from metadata, he will not be able to migrate from Icehouse to
    Juno. Only databases created by alembic could be migrated to the later
    version.

    Closes-Bug: #1300190
    Change-Id: I991aa3402f658999735ad9607544251a6ef0e122

Changed in sahara:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in sahara:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in sahara:
milestone: icehouse-rc1 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.