diff --git a/releasenotes/notes/fix-cluster-type-error-71cd846897dfd32e.yaml b/releasenotes/notes/fix-cluster-type-error-71cd846897dfd32e.yaml new file mode 100644 index 0000000000..9b802f15ea --- /dev/null +++ b/releasenotes/notes/fix-cluster-type-error-71cd846897dfd32e.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - This would apply to any type of cluster that uses the galera strategy + while setting the nics on a create call. When we called cast to set() + the object was a list of lists. The set method can not has a list so + this was causesing a unhashable error. The change is to make the + instance_nics a list of strings (what we originaly expected) to + resolve this issue. Bug 1570602. diff --git a/trove/common/strategies/cluster/experimental/galera_common/api.py b/trove/common/strategies/cluster/experimental/galera_common/api.py index 58f833e26f..c4bd58b27c 100644 --- a/trove/common/strategies/cluster/experimental/galera_common/api.py +++ b/trove/common/strategies/cluster/experimental/galera_common/api.py @@ -98,12 +98,16 @@ class GaleraCommonCluster(cluster_models.Cluster): check_quotas(context.tenant, deltas) # Checking networks are same for the cluster - instance_nics = [instance.get('nics', None) for instance in instances] - if len(set(instance_nics)) != 1: + instance_nics = [] + for instance in instances: + nics = instance.get('nics') + if nics: + instance_nics.append(nics[0].get('net-id')) + if len(set(instance_nics)) > 1: raise exception.ClusterNetworksNotEqual() - instance_nic = instance_nics[0] - if instance_nic is None: + if not instance_nics: return + instance_nic = instance_nics[0] try: nova_client.networks.get(instance_nic) except nova_exceptions.NotFound: diff --git a/trove/tests/unittests/cluster/test_galera_cluster.py b/trove/tests/unittests/cluster/test_galera_cluster.py index 960a6c01bc..a5f11214dc 100644 --- a/trove/tests/unittests/cluster/test_galera_cluster.py +++ b/trove/tests/unittests/cluster/test_galera_cluster.py @@ -65,9 +65,13 @@ class ClusterTest(trove_testtools.TestCase): self.datastore_version = self.dv self.cluster = galera_api.GaleraCommonCluster( self.context, self.db_info, self.datastore, self.datastore_version) - self.instances = [{'volume_size': 1, 'flavor_id': '1234'}, - {'volume_size': 1, 'flavor_id': '1234'}, - {'volume_size': 1, 'flavor_id': '1234'}] + self.instances = [ + {'volume_size': 1, 'flavor_id': '1234', + 'nics': [{"net-id": "foo-bar"}]}, + {'volume_size': 1, 'flavor_id': '1234', + 'nics': [{"net-id": "foo-bar"}]}, + {'volume_size': 1, 'flavor_id': '1234', + 'nics': [{"net-id": "foo-bar"}]}] def tearDown(self): super(ClusterTest, self).tearDown()