Browse Source

NetApp: Define 'preferred' to False instead of none

Define preferred to false instead of none in the NetApp driver
as setting it to none will trigger a traceback later on because
the database doesn't allow null values to be inserted.
"preferred" export location metadata must be set to true or
false.  warning logging is also added to the SQLAlchemy API
if a none value is used to update the export location metadata.

Change-Id: Ie7420c9286cc42eaa1361eeffe607b9b5b6b3fbd
Closes-Bug: 1703660
(cherry picked from commit 4573826d36)
tags/4.0.1
Dave Hill 1 year ago
parent
commit
0a5d760ed5

+ 5
- 0
manila/db/sqlalchemy/api.py View File

@@ -2855,6 +2855,11 @@ def export_location_metadata_update(context, export_location_uuid, metadata,
2855 2855
         # that will not take effect using one session and we will rewrite,
2856 2856
         # in that case, single record - first one added with this call.
2857 2857
         session = get_session()
2858
+
2859
+        if meta_value is None:
2860
+            LOG.warning(_LW("%s should be properly defined in the driver."),
2861
+                        meta_key)
2862
+
2858 2863
         item = {"value": meta_value, "updated_at": timeutils.utcnow()}
2859 2864
 
2860 2865
         meta_ref = _export_location_metadata_get_query(

+ 1
- 1
manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py View File

@@ -742,7 +742,7 @@ class NetAppCmodeFileStorageLibrary(object):
742 742
             if home_node:
743 743
                 preferred = interface.get('home-node') == home_node
744 744
             else:
745
-                preferred = None
745
+                preferred = False
746 746
 
747 747
             addresses[address] = {
748 748
                 'is_admin_only': is_admin_only,

+ 1
- 1
manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py View File

@@ -1120,7 +1120,7 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
1120 1120
 
1121 1121
         expected = copy.deepcopy(fake.INTERFACE_ADDRESSES_WITH_METADATA)
1122 1122
         for key, value in expected.items():
1123
-            value['preferred'] = None
1123
+            value['preferred'] = False
1124 1124
 
1125 1125
         self.assertEqual(expected, result)
1126 1126
         mock_get_aggregate_node.assert_called_once_with(fake.POOL_NAME)

+ 6
- 0
releasenotes/notes/bug-1703660-fix-netapp-driver-preferred-state-0ce1a62961cded35.yaml View File

@@ -0,0 +1,6 @@
1
+---
2
+fixes:
3
+  - |
4
+    Fixed the NetApp driver to report the correct value of the "preferred"
5
+    export location metadata where it cannot determine if there are any
6
+    "preferred" export locations.

Loading…
Cancel
Save