diff options
author | Lingxian Kong <anlin.kong@gmail.com> | 2020-08-02 21:44:48 +1200 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2020-08-03 21:11:53 +1200 |
commit | 695a63e228548349cfc8d7ced75ecc53e1b1f984 (patch) | |
tree | a0cba57cc03af4356dc17a78f65284b21469a5d8 | |
parent | c5d78f68925b0f73e85c39308439eec0f20aad9f (diff) | |
download | trove-695a63e228548349cfc8d7ced75ecc53e1b1f984.tar.gz |
Do not operate floating IP for relication cluster
Change-Id: I44e134efbd5939962a508468584defcf4cb4c0c5
-rw-r--r-- | .zuul.yaml | 18 | ||||
-rw-r--r-- | trove/taskmanager/manager.py | 13 | ||||
-rwxr-xr-x | trove/taskmanager/models.py | 45 | ||||
-rw-r--r-- | trove/tests/unittests/taskmanager/test_models.py | 28 |
4 files changed, 12 insertions, 92 deletions
@@ -11,7 +11,6 @@ jobs: - openstack-tox-cover: voting: false - - openstack-tox-pylint - trove-tox-bandit-baseline: voting: false - trove-tempest: @@ -33,7 +32,6 @@ gate: queue: trove jobs: - - openstack-tox-pylint - trove-functional-mysql - trove-scenario-mysql-single - trove-scenario-mysql-multi @@ -361,6 +359,10 @@ $TROVE_CONF: DEFAULT: usage_timeout: 1800 + test-config: + $TEMPEST_CONFIG: + database: + default_datastore_versions: mysql:5.7 devstack_plugins: trove: https://opendev.org/openstack/trove.git devstack_services: @@ -378,13 +380,13 @@ c-api: true c-vol: true c-bak: false - swift: true - s-account: true - s-container: true - s-object: true - s-proxy: true + swift: false + s-account: false + s-container: false + s-object: false + s-proxy: false tempest: true - tempest_test_regex: ^trove_tempest_plugin\.tests + tempest_test_regex: trove_tempest_plugin.tests.scenario.test_instance_basic.TestInstanceBasicMySQL.test_database_access - job: name: publish-trove-guest-image diff --git a/trove/taskmanager/manager.py b/trove/taskmanager/manager.py index b103704b..45ba12e1 100644 --- a/trove/taskmanager/manager.py +++ b/trove/taskmanager/manager.py @@ -108,25 +108,21 @@ class Manager(periodic_task.PeriodicTasks): # the replicas to the new master, 'START SLAVE' will fail by # 'fatal error 1236' if the binlog of the replica diverged from # the new master. So the proper order should be: - # -1. make the old master read only (and detach floating ips) + # -1. make the old master read only # -2. make sure the new master is up-to-date # -3. detach the new master from the old one - # -4. enable the new master (and attach floating ips) + # -4. enable the new master # -5. attach the other replicas to the new master # -6. attach the old master to the new one - # (and attach floating ips) # -7. demote the old master # What we changed here is the order of the 6th step, previously # this step took place right after step 4, which causes failures # with MariaDB replications. old_master.make_read_only(True) - master_ips = old_master.detach_public_ips() - slave_ips = master_candidate.detach_public_ips() latest_txn_id = old_master.get_latest_txn_id() master_candidate.wait_for_txn(latest_txn_id) master_candidate.detach_replica(old_master, for_failover=True) master_candidate.enable_as_master() - master_candidate.attach_public_ips(master_ips) master_candidate.make_read_only(False) # At this point, should something go wrong, there @@ -159,7 +155,6 @@ class Manager(periodic_task.PeriodicTasks): # dealing with the old master after all the other replicas # has been migrated. old_master.attach_replica(master_candidate) - old_master.attach_public_ips(slave_ips) try: old_master.demote_replication_master() except Exception as ex: @@ -225,13 +220,9 @@ class Manager(periodic_task.PeriodicTasks): master_candidate = self._most_current_replica(old_master, replica_models) - master_ips = old_master.detach_public_ips() - slave_ips = master_candidate.detach_public_ips() master_candidate.detach_replica(old_master, for_failover=True) master_candidate.enable_as_master() - master_candidate.attach_public_ips(master_ips) master_candidate.make_read_only(False) - old_master.attach_public_ips(slave_ips) exception_replicas = [] error_messages = "" diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index da3ad45a..9e3253f3 100755 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -21,7 +21,6 @@ from cinderclient import exceptions as cinder_exceptions from eventlet import greenthread from eventlet.timeout import Timeout from oslo_log import log as logging -from oslo_utils import netutils from swiftclient.client import ClientException from trove.backup import models as bkup_models @@ -1159,50 +1158,6 @@ class BuiltInstanceTasks(BuiltInstance, NotifyMixin, ConfigurationMixin): LOG.debug("Calling make_read_only on %s", self.id) self.guest.make_read_only(read_only) - def _get_floating_ips(self): - """Returns floating ips as a dict indexed by the ip.""" - floating_ips = {} - network_floating_ips = self.neutron_client.list_floatingips() - for ip in network_floating_ips.get('floatingips'): - floating_ips.update( - {ip.get('floating_ip_address'): ip.get('id')}) - LOG.debug("In _get_floating_ips(), returning %s", floating_ips) - return floating_ips - - def detach_public_ips(self): - LOG.debug("Begin detach_public_ips for instance %s", self.id) - removed_ips = [] - floating_ips = self._get_floating_ips() - for ip in self.get_visible_ip_addresses(): - if ip in floating_ips: - fip_id = floating_ips[ip] - self.neutron_client.update_floatingip( - fip_id, {'floatingip': {'port_id': None}}) - removed_ips.append(fip_id) - return removed_ips - - def attach_public_ips(self, ips): - LOG.debug("Begin attach_public_ips for instance %s", self.id) - server_id = self.db_info.compute_instance_id - - # NOTE(zhaochao): in Nova's addFloatingIp, the new floating ip will - # always be associated with the first IPv4 fixed address of the Nova - # instance, we're doing the same thing here, after add_floating_ip is - # removed from novaclient. - server_ports = (self.neutron_client.list_ports(device_id=server_id) - .get('ports')) - fixed_address, port_id = next( - (fixed_ip['ip_address'], port['id']) - for port in server_ports - for fixed_ip in port.get('fixed_ips') - if netutils.is_valid_ipv4(fixed_ip['ip_address'])) - - for fip_id in ips: - self.neutron_client.update_floatingip( - fip_id, {'floatingip': { - 'port_id': port_id, - 'fixed_ip_address': fixed_address}}) - def enable_as_master(self): LOG.debug("Calling enable_as_master on %s", self.id) flavor = self.nova_client.flavors.get(self.flavor_id) diff --git a/trove/tests/unittests/taskmanager/test_models.py b/trove/tests/unittests/taskmanager/test_models.py index 9ac99a69..e6c0cf51 100644 --- a/trove/tests/unittests/taskmanager/test_models.py +++ b/trove/tests/unittests/taskmanager/test_models.py @@ -926,34 +926,6 @@ class BuiltInstanceTasksTest(trove_testtools.TestCase): self.assertRaises(GuestError, self.instance_task.attach_replica, Mock()) - def test_get_floating_ips(self): - floating_ips = self.instance_task._get_floating_ips() - self.assertEqual({'192.168.10.1': 'fake-floatingip-id'}, - floating_ips) - - @patch.object(BaseInstance, 'get_visible_ip_addresses', - return_value=['192.168.10.1']) - def test_detach_public_ips(self, mock_address): - removed_ips = self.instance_task.detach_public_ips() - self.assertEqual(['fake-floatingip-id'], removed_ips) - mock_update_floatingip = (self.instance_task.neutron_client - .update_floatingip) - mock_update_floatingip.assert_called_once_with( - removed_ips[0], {'floatingip': {'port_id': None}}) - - def test_attach_public_ips(self): - self.instance_task.attach_public_ips(['fake-floatingip-id']) - mock_list_ports = (self.instance_task.neutron_client - .list_ports) - mock_list_ports.assert_called_once_with(device_id='computeinst-id-1') - - mock_update_floatingip = (self.instance_task.neutron_client - .update_floatingip) - mock_update_floatingip.assert_called_once_with( - 'fake-floatingip-id', - {'floatingip': {'port_id': 'fake-port-id', - 'fixed_ip_address': '10.0.0.1'}}) - @patch.object(BaseInstance, 'update_db') def test_enable_as_master(self, mock_update_db): test_func = self.instance_task._guest.enable_as_master |