Removes try except block from creation of database tables 68/7168/1
authorBenjamin Diaz <bdiaz@whitestack.com>
Thu, 3 Jan 2019 02:13:32 +0000 (23:13 -0300)
committerBenjamin Diaz <bdiaz@whitestack.com>
Fri, 1 Feb 2019 12:46:33 +0000 (09:46 -0300)
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 <bdiaz@whitestack.com>
osm_policy_module/core/database.py

index a39f982..db8cf28 100644 (file)
@@ -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()