From b77fe26906b4acdf5f2b110f07433382520f44ff Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Wed, 2 Jan 2019 23:13:32 -0300 Subject: [PATCH] Removes try except block from creation of database tables In case there is an error connecting to the database engine, or the database is not yet created, POL should fail. This is specially relevant to avoid race conditions in Docker and K8s deployments using MySQL/MariaDB, because peewee needs the database to already exist. Change-Id: Iabe46c1c4f718919e10fc65271d0e814c5f9a146 Signed-off-by: Benjamin Diaz --- osm_policy_module/core/database.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osm_policy_module/core/database.py b/osm_policy_module/core/database.py index a39f982..db8cf28 100644 --- a/osm_policy_module/core/database.py +++ b/osm_policy_module/core/database.py @@ -71,12 +71,9 @@ class ScalingAlarm(BaseModel): class DatabaseManager: def create_tables(self): - try: - db.connect() - db.create_tables([ScalingGroup, ScalingPolicy, ScalingCriteria, ScalingAlarm]) - db.close() - except Exception: - log.exception("Error creating tables: ") + db.connect() + db.create_tables([ScalingGroup, ScalingPolicy, ScalingCriteria, ScalingAlarm]) + db.close() def get_alarm(self, alarm_uuid: str): return ScalingAlarm.select().where(ScalingAlarm.alarm_uuid == alarm_uuid).get() -- 2.25.1