Bug 1469733 - metadata update fails if preferered is null as the database schema doesn't allows null value
metadata update fails if preferered is null as the database schema doesn't al...
Status: ASSIGNED
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-manila (Show other bugs)
10.0 (Newton)
Unspecified Unspecified
low Severity medium
: ---
: 10.0 (Newton)
Assigned To: Tom Barron
Dustin Schoenbrun
Don Domingo
: Triaged, ZStream
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-11 14:26 EDT by David Hill
Modified: 2018-02-07 22:03 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1473704 (view as bug list)
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Launchpad 1703660 None None None 2017-07-11 14:27 EDT
OpenStack gerrit 486666 None None None 2017-09-06 10:13 EDT

  None (edit)
Description David Hill 2017-07-11 14:26:14 EDT
Description of problem:
metadata update fails if preferered is null as the database schema doesn't allows null value and here is a patch to fix in in sqlalchemy:


2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/manila/db/sqlalchemy/api.py", line 2481, in share_export_locations_update
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     context, location_ref['uuid'], el.get('metadata'), session=session)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/manila/db/sqlalchemy/api.py", line 164, in wrapper
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     return f(*args, **kwargs)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_db/api.py", line 151, in wrapper
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     ectxt.value = e.inner_exc
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     self.force_reraise()
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     six.reraise(self.type_, self.value, self.tb)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_db/api.py", line 139, in wrapper
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     return f(*args, **kwargs)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/manila/db/sqlalchemy/api.py", line 2571, in export_location_metadata_update
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     meta_ref.save(session=session)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/models.py", line 48, in save
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     session.flush()
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 2027, in flush
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     self._flush(objects)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 2145, in _flush
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     transaction.rollback(_capture_exception=True)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     compat.reraise(exc_type, exc_value, exc_tb)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 2109, in _flush
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     flush_context.execute()
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     rec.execute(self)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     uow
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     mapper, table, insert)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 800, in _emit_insert_statements
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     execute(statement, params)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     return meth(self, multiparams, params)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     return connection._execute_clauseelement(self, multiparams, params)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     compiled_sql, distilled_params
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     context)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     util.raise_from_cause(newraise, exc_info)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     reraise(type(exception), exception, tb=exc_tb)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     context)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     cursor.execute(statement, parameters)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     self.errorhandler(self, exc, value)
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server   File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server     raise errorclass, errorvalue
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server OperationalError: (_mysql_exceptions.OperationalError) (1048, "Column 'value' cannot be null") [SQL: u'INSERT INTO share_instance_export_locations_metadata (created_at, updated_at, deleted_at, deleted, export_location_id, `key`, value) VALUES (%s, %s, %s, %s, %s, %s, %s)'] [parameters: (datetime.datetime(2017, 7, 11, 18, 10, 14, 927115), datetime.datetime(2017, 7, 11, 18, 10, 14, 901766), None, 0, 21L, 'preferred', None)]
2017-07-11 14:10:14.960 23536 ERROR oslo_messaging.rpc.server 

[root@lab-openstack01 sqlalchemy(keystone_admin)]# diff -u api.py.orig api.py
--- api.py.orig	2017-07-11 13:47:55.591859922 -0400
+++ api.py	2017-07-11 14:15:32.904711884 -0400
@@ -2546,6 +2546,8 @@
         # that will not take effect using one session and we will rewrite,
         # in that case, single record - first one added with this call.
         session = get_session()
+ if not meta_value:
+ meta_value = 'none'
         item = {"value": meta_value, "updated_at": timeutils.utcnow()}

         meta_ref = _export_location_metadata_get_query(




https://bugs.launchpad.net/manila/+bug/1703660

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Install latest manila packages for RHOSP 10 while manila.conf is using a netapp user that doesn't have cluster administration privilege
2.
3.

Actual results:
Fails inserting the share instance metadata in the database

Expected results:
Succeeds in doing so

Additional info:
We live-patched the system with the above patch and we can confirm it works
Comment 1 David Hill 2017-07-11 15:06:21 EDT
The following patch [1] was pushed upstream

[1] https://review.openstack.org/482672

Note You need to log in before you can comment on or make changes to this bug.