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'