summaryrefslogtreecommitdiff
path: root/trove/db
diff options
context:
space:
mode:
authorPeter Stachowski <peter@tesora.com>2016-05-05 11:37:30 -0400
committerPeter Stachowski <peter@tesora.com>2016-07-01 22:27:30 +0000
commit2a9fa44364cccfb3535535d41cdeaa18ef1d7a33 (patch)
tree275026e5a60245f6858990c5abd039c017699863 /trove/db
parentd412c3c0feaeb9b207611d27bd89096ab388a43d (diff)
downloadtrove-2a9fa44364cccfb3535535d41cdeaa18ef1d7a33.tar.gz
Persist error messages and display on 'show'
When an error occurs in Trove, it is very difficult to determine the cause without access to the server logs. To make these errors available to the end user, they are now persisted in the database and can be viewed using the standard 'show' command. Also fixed TESTS_USE_INSTANCE_ID test path, as it somehow got broken over time. Change-Id: I84ed28ee73a24a2dd6bdbf895662d26e406e9fae Depends-On: I5d3339e9cbfd6aeb0c3ff6936fefa8dbe9e841f8 Implements: blueprint persist-error-message
Diffstat (limited to 'trove/db')
-rw-r--r--trove/db/sqlalchemy/mappers.py2
-rw-r--r--trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py56
2 files changed, 58 insertions, 0 deletions
diff --git a/trove/db/sqlalchemy/mappers.py b/trove/db/sqlalchemy/mappers.py
index 68063ba9..ff90e262 100644
--- a/trove/db/sqlalchemy/mappers.py
+++ b/trove/db/sqlalchemy/mappers.py
@@ -26,6 +26,8 @@ def map(engine, models):
return
orm.mapper(models['instance'], Table('instances', meta, autoload=True))
+ orm.mapper(models['instance_faults'],
+ Table('instance_faults', meta, autoload=True))
orm.mapper(models['root_enabled_history'],
Table('root_enabled_history', meta, autoload=True))
orm.mapper(models['datastore'],
diff --git a/trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py b/trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py
new file mode 100644
index 00000000..49b4570c
--- /dev/null
+++ b/trove/db/sqlalchemy/migrate_repo/versions/038_instance_faults.py
@@ -0,0 +1,56 @@
+# Copyright 2016 Tesora, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+from sqlalchemy import ForeignKey
+from sqlalchemy.schema import Column
+from sqlalchemy.schema import MetaData
+
+from trove.db.sqlalchemy.migrate_repo.schema import Boolean
+from trove.db.sqlalchemy.migrate_repo.schema import create_tables
+from trove.db.sqlalchemy.migrate_repo.schema import DateTime
+from trove.db.sqlalchemy.migrate_repo.schema import drop_tables
+from trove.db.sqlalchemy.migrate_repo.schema import String
+from trove.db.sqlalchemy.migrate_repo.schema import Table
+from trove.db.sqlalchemy.migrate_repo.schema import Text
+
+
+meta = MetaData()
+
+instance_faults = Table(
+ 'instance_faults',
+ meta,
+ Column('id', String(length=64), primary_key=True, nullable=False),
+ Column('instance_id', String(length=64),
+ ForeignKey('instances.id', ondelete="CASCADE",
+ onupdate="CASCADE"), nullable=False),
+ Column('message', String(length=255), nullable=False),
+ Column('details', Text(length=65535), nullable=False),
+ Column('created', DateTime(), nullable=False),
+ Column('updated', DateTime(), nullable=False),
+ Column('deleted', Boolean(), default=0, nullable=False),
+ Column('deleted_at', DateTime()),
+)
+
+
+def upgrade(migrate_engine):
+ meta.bind = migrate_engine
+ Table('instances', meta, autoload=True)
+ create_tables([instance_faults])
+
+
+def downgrade(migrate_engine):
+ meta.bind = migrate_engine
+ drop_tables([instance_faults])