Change status_reason column's type to TEXT
This patch changes status_reason column's type of 'action, cluster, event, node' tables to TEXT. Change-Id: Iddb6b21649b6829beee2aed22ca89f7267d16f88 Closes-Bug: #1469100
This commit is contained in:
parent
edc1f3dbe8
commit
0fdd7ec3c4
@ -162,8 +162,6 @@ def _session(context):
|
||||
# Clusters
|
||||
def cluster_create(context, values):
|
||||
cluster_ref = models.Cluster()
|
||||
if 'status_reason' in values:
|
||||
values['status_reason'] = values['status_reason'][:255]
|
||||
cluster_ref.update(values)
|
||||
cluster_ref.save(_session(context))
|
||||
return cluster_ref
|
||||
@ -290,8 +288,6 @@ def node_create(context, values):
|
||||
# This operation is always called with cluster and node locked
|
||||
session = _session(context)
|
||||
node = models.Node()
|
||||
if 'status_reason' in values:
|
||||
values['status_reason'] = values['status_reason'][:255]
|
||||
node.update(values)
|
||||
cluster_id = values.get('cluster_id', None)
|
||||
if cluster_id is not None:
|
||||
@ -925,8 +921,6 @@ def event_prune(context, cluster_id):
|
||||
|
||||
def event_create(context, values):
|
||||
event = models.Event()
|
||||
if 'status_reason' in values:
|
||||
values['status_reason'] = values['status_reason'][:255]
|
||||
event.update(values)
|
||||
event.save(_session(context))
|
||||
return event
|
||||
|
@ -59,7 +59,7 @@ def upgrade(migrate_engine):
|
||||
sqlalchemy.Column('next_index', sqlalchemy.Integer),
|
||||
sqlalchemy.Column('timeout', sqlalchemy.Integer),
|
||||
sqlalchemy.Column('status', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.Text),
|
||||
sqlalchemy.Column('meta_data', types.Dict),
|
||||
sqlalchemy.Column('data', types.Dict),
|
||||
mysql_engine='InnoDB',
|
||||
@ -87,7 +87,7 @@ def upgrade(migrate_engine):
|
||||
sqlalchemy.Column('updated_time', sqlalchemy.DateTime),
|
||||
sqlalchemy.Column('deleted_time', sqlalchemy.DateTime),
|
||||
sqlalchemy.Column('status', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.Text),
|
||||
sqlalchemy.Column('meta_data', types.Dict),
|
||||
sqlalchemy.Column('data', types.Dict),
|
||||
mysql_engine='InnoDB',
|
||||
@ -199,7 +199,7 @@ def upgrade(migrate_engine):
|
||||
sqlalchemy.Column('timeout', sqlalchemy.Integer),
|
||||
sqlalchemy.Column('control', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.Text),
|
||||
sqlalchemy.Column('inputs', types.Dict),
|
||||
sqlalchemy.Column('outputs', types.Dict),
|
||||
sqlalchemy.Column('depends_on', types.List),
|
||||
@ -227,7 +227,7 @@ def upgrade(migrate_engine):
|
||||
sqlalchemy.Column('project', sqlalchemy.String(32)),
|
||||
sqlalchemy.Column('action', sqlalchemy.String(36)),
|
||||
sqlalchemy.Column('status', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.String(255)),
|
||||
sqlalchemy.Column('status_reason', sqlalchemy.Text),
|
||||
sqlalchemy.Column('meta_data', types.Dict),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
|
@ -110,7 +110,7 @@ class Cluster(BASE, SenlinBase, SoftDelete):
|
||||
timeout = sqlalchemy.Column(sqlalchemy.Integer)
|
||||
|
||||
status = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.Text)
|
||||
meta_data = sqlalchemy.Column(types.Dict)
|
||||
data = sqlalchemy.Column(types.Dict)
|
||||
|
||||
@ -140,7 +140,7 @@ class Node(BASE, SenlinBase, SoftDelete):
|
||||
deleted_time = sqlalchemy.Column(sqlalchemy.DateTime)
|
||||
|
||||
status = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.Text)
|
||||
meta_data = sqlalchemy.Column(types.Dict)
|
||||
data = sqlalchemy.Column(types.Dict)
|
||||
|
||||
@ -287,7 +287,7 @@ class Action(BASE, SenlinBase, SoftDelete):
|
||||
end_time = sqlalchemy.Column(sqlalchemy.Float)
|
||||
timeout = sqlalchemy.Column(sqlalchemy.Integer)
|
||||
status = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.Text)
|
||||
control = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
inputs = sqlalchemy.Column(types.Dict)
|
||||
outputs = sqlalchemy.Column(types.Dict)
|
||||
@ -321,5 +321,5 @@ class Event(BASE, SenlinBase, SoftDelete):
|
||||
project = sqlalchemy.Column(sqlalchemy.String(32))
|
||||
action = sqlalchemy.Column(sqlalchemy.String(36))
|
||||
status = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.String(255))
|
||||
status_reason = sqlalchemy.Column(sqlalchemy.Text)
|
||||
meta_data = sqlalchemy.Column(types.Dict)
|
||||
|
@ -242,7 +242,6 @@ class Node(object):
|
||||
msg = six.text_type(ex)
|
||||
event_mod.warning(context, self, 'create', self.ERROR, msg)
|
||||
self.physical_id = ex.kwargs.get('resource_id')
|
||||
# TODO(xuhaiwei)Trim the error message, in case it is too long.
|
||||
reason = _('Profile failed in creating resource (%(id)s) due to: '
|
||||
'%(msg)s') % {'id': self.physical_id, 'msg': msg}
|
||||
self.set_status(context, self.ERROR, reason)
|
||||
|
@ -536,11 +536,6 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
||||
self.assertIsNone(db_api.cluster_get(ctx, clusters[s].id,
|
||||
show_deleted=True))
|
||||
|
||||
def test_cluster_status_reason_truncate(self):
|
||||
cluster = shared.create_cluster(self.ctx, self.profile,
|
||||
status_reason='a' * 1024)
|
||||
self.assertEqual('a' * 255, cluster.status_reason)
|
||||
|
||||
def test_cluster_delete(self):
|
||||
cluster = shared.create_cluster(self.ctx, self.profile)
|
||||
cluster_id = cluster.id
|
||||
|
@ -345,11 +345,6 @@ class DBAPIEventTest(base.SenlinTestCase):
|
||||
self.assertEqual(1, db_api.event_count_by_cluster(self.ctx,
|
||||
cluster2.id))
|
||||
|
||||
def test_event_node_status_reason_truncate(self):
|
||||
event = self.create_event(self.ctx, status_reason='a' * 1024)
|
||||
ret_event = db_api.event_get(self.ctx, event.id)
|
||||
self.assertEqual('a' * 255, ret_event.status_reason)
|
||||
|
||||
def test_event_get_all_filtered(self):
|
||||
cluster1 = shared.create_cluster(self.ctx, self.profile,
|
||||
name='cluster1')
|
||||
|
@ -55,12 +55,6 @@ class DBAPINodeTest(base.SenlinTestCase):
|
||||
nodes = db_api.node_get_all_by_cluster(self.ctx, self.cluster.id)
|
||||
self.assertEqual(1, len(nodes))
|
||||
|
||||
def test_node_status_reason_truncate(self):
|
||||
node = shared.create_node(self.ctx, self.cluster, self.profile,
|
||||
status_reason='a' * 1024)
|
||||
ret_node = db_api.node_get(self.ctx, node.id)
|
||||
self.assertEqual('a' * 255, ret_node.status_reason)
|
||||
|
||||
def test_node_get(self):
|
||||
res = shared.create_node(self.ctx, self.cluster, self.profile)
|
||||
node = db_api.node_get(self.ctx, res.id)
|
||||
|
Loading…
Reference in New Issue
Block a user