Exit with error code when db_manage.py fails

The DB migration script db_manage.py always returned a 0 exit code,
even if errors were seen. This would break use of this script in
automation since the next sequence in the workflow would always be
executed even on errors. This script should return a 1 if errors are
seen. This CR adds that error code return.

Closes-bug: #1500448
Change-Id: I9f51bca409d23a90f629acb124938ecefa11208a
(cherry picked from commit 3e088f2619)
This commit is contained in:
jfwood 2015-09-28 09:02:33 -05:00 committed by Douglas Mendizábal
parent f03dc6006e
commit 3cf0501dfc
1 changed files with 4 additions and 3 deletions

View File

@ -135,9 +135,10 @@ def main():
dm = DatabaseManager(CONF)
dm.execute()
except Exception as ex:
if _exception_is_successfull_exit(ex):
pass
LOG.exception('Problem trying to execute Alembic commands')
if not _exception_is_successfull_exit(ex):
LOG.exception('Problem seen trying to execute Alembic commands')
sys.stderr.write("ERROR: {0}\n".format(ex))
sys.exit(1)
if __name__ == '__main__':