Limit instance fault messages to 255 characters
The instance_fault.message column is a VARCHAR(255). By default, MySQL silently truncates entries that are too long. PostgreSQL throws an error instead. So we need to truncate the message field before we try inserting into that column, to avoid errors from very long messages in PostgreSQL (or MySQL configured to not allow this). Fixes bug #1217167 Change-Id: Ia959d64a8bc162a33ba818f1006e9779207b4796
This commit is contained in:
		| @@ -62,6 +62,10 @@ def add_instance_fault_from_exc(context, conductor, | ||||
|             message = None | ||||
|     if not message: | ||||
|         message = fault.__class__.__name__ | ||||
|     # NOTE(dripton) The message field in the database is limited to 255 chars. | ||||
|     # MySQL silently truncates overly long messages, but PostgreSQL throws an | ||||
|     # error if we don't truncate it. | ||||
|     u_message = unicode(message)[:255] | ||||
|     details = '' | ||||
|  | ||||
|     if exc_info and code == 500: | ||||
| @@ -71,7 +75,7 @@ def add_instance_fault_from_exc(context, conductor, | ||||
|     values = { | ||||
|         'instance_uuid': instance['uuid'], | ||||
|         'code': code, | ||||
|         'message': unicode(message), | ||||
|         'message': u_message, | ||||
|         'details': unicode(details), | ||||
|         'host': CONF.host | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Ripton
					David Ripton