From 7b6e6e9b6e640f7f134cda02839f536531dc80fe Mon Sep 17 00:00:00 2001 From: Liam Young Date: Tue, 19 Apr 2016 08:50:05 +0000 Subject: [PATCH] Do not run db migration on Icehouse The neutron-server process performs the db migration on icehouse so check the Openstack version before running it Closes-Bug: 1571782 Change-Id: Ib9a57eea296a3116c69551c057f1cf9093ac93a8 --- hooks/neutron_api_hooks.py | 4 ++++ unit_tests/test_neutron_api_hooks.py | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hooks/neutron_api_hooks.py b/hooks/neutron_api_hooks.py index 1d929fe6..7988b85f 100755 --- a/hooks/neutron_api_hooks.py +++ b/hooks/neutron_api_hooks.py @@ -118,6 +118,10 @@ CONFIGS = register_configs() def conditional_neutron_migration(): + if os_release('neutron-server') <= 'icehouse': + log('Not running neutron database migration as migrations are handled ' + 'by the neutron-server process.') + return if is_elected_leader(CLUSTER_RES): allowed_units = relation_get('allowed_units') if allowed_units and local_unit() in allowed_units.split(): diff --git a/unit_tests/test_neutron_api_hooks.py b/unit_tests/test_neutron_api_hooks.py index 5d853f56..58324c9c 100644 --- a/unit_tests/test_neutron_api_hooks.py +++ b/unit_tests/test_neutron_api_hooks.py @@ -863,11 +863,21 @@ class NeutronAPIHooksTests(CharmTestCase): }) self.local_unit.return_value = 'neutron-api/1' self.is_elected_leader.return_value = True - self.os_release.return_value = 'icehouse' + self.os_release.return_value = 'kilo' hooks.conditional_neutron_migration() self.migrate_neutron_database.assert_called_with() self.service_restart.assert_called_with('neutron-server') + def test_conditional_neutron_migration_leader_icehouse(self): + self.test_relation.set({ + 'allowed_units': 'neutron-api/0 neutron-api/1 neutron-api/4', + }) + self.local_unit.return_value = 'neutron-api/1' + self.is_elected_leader.return_value = True + self.os_release.return_value = 'icehouse' + hooks.conditional_neutron_migration() + self.assertFalse(self.migrate_neutron_database.called) + def test_conditional_neutron_migration_notleader(self): self.is_elected_leader.return_value = False self.os_release.return_value = 'icehouse'