From: Benjamin Diaz Date: Thu, 3 Jan 2019 02:13:32 +0000 (-0300) Subject: Removes try except block from creation of database tables X-Git-Tag: v6.0.0~16 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FPOL.git;a=commitdiff_plain;h=refs%2Fchanges%2F68%2F7168%2F1 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 --- 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()