From 46f0b43dd3f06130492ae981a40a08f10aba44dc Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 21 Dec 2017 12:09:33 +0000 Subject: [PATCH] Drop postgresql support Remove postgresql DB support; This feature is untested as part of the charms, is not in use and was deprecated as part of the 1708 charms release. Change-Id: I456125442dd721c1b7b48b000fe4b4e4322bb476 --- hooks/cinder_hooks.py | 37 +------------------------ hooks/cinder_utils.py | 3 +-- hooks/pgsql-db-relation-broken | 1 - hooks/pgsql-db-relation-changed | 1 - hooks/pgsql-db-relation-joined | 1 - metadata.yaml | 2 -- unit_tests/test_cinder_hooks.py | 48 --------------------------------- unit_tests/test_cinder_utils.py | 4 +-- 8 files changed, 4 insertions(+), 93 deletions(-) delete mode 120000 hooks/pgsql-db-relation-broken delete mode 120000 hooks/pgsql-db-relation-changed delete mode 120000 hooks/pgsql-db-relation-joined diff --git a/hooks/cinder_hooks.py b/hooks/cinder_hooks.py index e34d3b1d..0a67ebe5 100755 --- a/hooks/cinder_hooks.py +++ b/hooks/cinder_hooks.py @@ -51,7 +51,6 @@ from charmhelpers.core.hookenv import ( Hooks, UnregisteredHookError, config, - is_relation_made, local_unit, relation_get, relation_ids, @@ -60,7 +59,6 @@ from charmhelpers.core.hookenv import ( service_name, log, DEBUG, - ERROR, WARNING, status_set, open_port, @@ -211,13 +209,6 @@ def config_changed(): @hooks.hook('shared-db-relation-joined') def db_joined(): - if is_relation_made('pgsql-db'): - # error, postgresql is used - e = ('Attempting to associate a mysql database when there is already ' - 'associated a postgresql one') - log(e, level=ERROR) - raise Exception(e) - if config('prefer-ipv6'): sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) @@ -237,19 +228,6 @@ def db_joined(): hostname=host) -@hooks.hook('pgsql-db-relation-joined') -def pgsql_db_joined(): - if is_relation_made('shared-db'): - # raise error - e = ('Attempting to associate a postgresql database when there is' - ' already associated a mysql one') - log(e, level=ERROR) - raise Exception(e) - - conf = config() - relation_set(database=conf['database']) - - @hooks.hook('shared-db-relation-changed') @restart_on_change(restart_map()) def db_changed(): @@ -270,18 +248,6 @@ def db_changed(): 'not in acl list: %s' % repr(allowed_units)) -@hooks.hook('pgsql-db-relation-changed') -@restart_on_change(restart_map()) -def pgsql_db_changed(): - if 'pgsql-db' not in CONFIGS.complete_contexts(): - juju_log('pgsql-db relation incomplete. Peer not ready?') - return - CONFIGS.write(CINDER_CONF) - if is_elected_leader(CLUSTER_RES): - juju_log('Cluster leader, performing db sync') - migrate_database() - - @hooks.hook('amqp-relation-joined') def amqp_joined(relation_id=None): conf = config() @@ -583,8 +549,7 @@ def image_service_changed(): @hooks.hook('amqp-relation-broken', 'identity-service-relation-broken', 'image-service-relation-broken', - 'shared-db-relation-broken', - 'pgsql-db-relation-broken') + 'shared-db-relation-broken') @restart_on_change(restart_map(), stopstart=True) def relation_broken(): CONFIGS.write_all() diff --git a/hooks/cinder_utils.py b/hooks/cinder_utils.py index cc2e8c11..c0c3fe9b 100644 --- a/hooks/cinder_utils.py +++ b/hooks/cinder_utils.py @@ -201,7 +201,7 @@ TEMPLATES = 'templates/' # the # list has a complete context. REQUIRED_INTERFACES = { - 'database': ('shared-db', 'pgsql-db'), + 'database': ('shared-db',), 'messaging': ('amqp',), 'identity': ('identity-service',), } @@ -225,7 +225,6 @@ def ceph_config_file(): BASE_RESOURCE_MAP = OrderedDict([ (CINDER_CONF, { 'contexts': [context.SharedDBContext(ssl_dir=CINDER_CONF_DIR), - context.PostgresqlDBContext(), context.AMQPContext(ssl_dir=CINDER_CONF_DIR), context.ImageServiceContext(), context.OSConfigFlagContext(), diff --git a/hooks/pgsql-db-relation-broken b/hooks/pgsql-db-relation-broken deleted file mode 120000 index 6dcd0084..00000000 --- a/hooks/pgsql-db-relation-broken +++ /dev/null @@ -1 +0,0 @@ -cinder_hooks.py \ No newline at end of file diff --git a/hooks/pgsql-db-relation-changed b/hooks/pgsql-db-relation-changed deleted file mode 120000 index 6dcd0084..00000000 --- a/hooks/pgsql-db-relation-changed +++ /dev/null @@ -1 +0,0 @@ -cinder_hooks.py \ No newline at end of file diff --git a/hooks/pgsql-db-relation-joined b/hooks/pgsql-db-relation-joined deleted file mode 120000 index 6dcd0084..00000000 --- a/hooks/pgsql-db-relation-joined +++ /dev/null @@ -1 +0,0 @@ -cinder_hooks.py \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index 2778e7f7..a7b36e29 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -25,8 +25,6 @@ provides: requires: shared-db: interface: mysql-shared - pgsql-db: - interface: pgsql amqp: interface: rabbitmq identity-service: diff --git a/unit_tests/test_cinder_hooks.py b/unit_tests/test_cinder_hooks.py index cbc398d2..bf7ee01e 100644 --- a/unit_tests/test_cinder_hooks.py +++ b/unit_tests/test_cinder_hooks.py @@ -70,7 +70,6 @@ TO_PATCH = [ 'update_nrpe_config', # charmhelpers.core.hookenv 'config', - 'is_relation_made', 'local_unit', 'relation_get', 'relation_ids', @@ -300,13 +299,6 @@ class TestChangedHooks(CharmTestCase): self.CONFIGS.write.assert_called_with('/etc/cinder/cinder.conf') self.assertTrue(self.migrate_database.called) - def test_pgsql_db_changed(self): - 'It writes out cinder.conf on db changed' - self.CONFIGS.complete_contexts.return_value = ['pgsql-db'] - hooks.hooks.execute(['hooks/pgsql-db-relation-changed']) - self.CONFIGS.write.assert_called_with('/etc/cinder/cinder.conf') - self.assertTrue(self.migrate_database.called) - def test_db_changed_relation_incomplete(self): 'It does not write out cinder.conf with incomplete shared-db rel' self.relation_get.return_value = 'cinder/0 cinder/1' @@ -333,12 +325,6 @@ class TestChangedHooks(CharmTestCase): hooks.hooks.execute(['hooks/shared-db-relation-changed']) self.assertFalse(self.migrate_database.called) - def test_pgsql_db_changed_relation_incomplete(self): - 'It does not write out cinder.conf with incomplete pgsql-db rel' - hooks.hooks.execute(['hooks/pgsql-db-relation-changed']) - self.assertFalse(self.CONFIGS.write.called) - self.assertFalse(self.migrate_database.called) - def test_db_changed_not_leader(self): 'It does not migrate database when not leader' self.relation_get.return_value = 'cinder/0 cinder/1' @@ -349,14 +335,6 @@ class TestChangedHooks(CharmTestCase): self.CONFIGS.write.assert_called_with('/etc/cinder/cinder.conf') self.assertFalse(self.migrate_database.called) - def test_pgsql_db_changed_not_leader(self): - 'It does not migrate database when not leader' - self.is_elected_leader.return_value = False - self.CONFIGS.complete_contexts.return_value = ['pgsql-db'] - hooks.hooks.execute(['hooks/pgsql-db-relation-changed']) - self.CONFIGS.write.assert_called_with('/etc/cinder/cinder.conf') - self.assertFalse(self.migrate_database.called) - def test_amqp_changed(self): 'It writes out cinder.conf on amqp changed with complete relation' self.CONFIGS.complete_contexts.return_value = ['amqp'] @@ -440,37 +418,11 @@ class TestJoinedHooks(CharmTestCase): def test_db_joined(self): 'It properly requests access to a shared-db service' self.get_relation_ip.return_value = '10.0.0.1' - self.is_relation_made.return_value = False hooks.hooks.execute(['hooks/shared-db-relation-joined']) expected = {'username': 'cinder', 'hostname': '10.0.0.1', 'database': 'cinder'} self.relation_set.assert_called_with(**expected) - def test_db_joined_with_postgresql(self): - self.is_relation_made.return_value = True - - with self.assertRaises(Exception) as context: - hooks.hooks.execute(['hooks/shared-db-relation-joined']) - self.assertEqual(context.exception.message, - 'Attempting to associate a mysql database when there ' - 'is already associated a postgresql one') - - def test_postgresql_db_joined(self): - 'It properly requests access to a postgresql-db service' - self.is_relation_made.return_value = False - hooks.hooks.execute(['hooks/pgsql-db-relation-joined']) - expected = {'database': 'cinder'} - self.relation_set.assert_called_with(**expected) - - def test_postgresql_joined_with_db(self): - self.is_relation_made.return_value = True - - with self.assertRaises(Exception) as context: - hooks.hooks.execute(['hooks/pgsql-db-relation-joined']) - self.assertEqual(context.exception.message, - 'Attempting to associate a postgresql database when' - ' there is already associated a mysql one') - def test_amqp_joined(self): 'It properly requests access to an amqp service' hooks.hooks.execute(['hooks/amqp-relation-joined']) diff --git a/unit_tests/test_cinder_utils.py b/unit_tests/test_cinder_utils.py index c7983250..d937027f 100644 --- a/unit_tests/test_cinder_utils.py +++ b/unit_tests/test_cinder_utils.py @@ -1058,7 +1058,7 @@ class TestCinderUtils(CharmTestCase): def test_required_interfaces_api(self): '''identity-service interface required for api service''' expected = { - 'database': ('shared-db', 'pgsql-db'), + 'database': ('shared-db',), 'messaging': ('amqp',), 'identity': ('identity-service',), } @@ -1071,7 +1071,7 @@ class TestCinderUtils(CharmTestCase): ''' self.test_config.set('enabled-services', 'volume,scheduler') expected = { - 'database': ('shared-db', 'pgsql-db'), + 'database': ('shared-db',), 'messaging': ('amqp',), } self.assertEqual(cinder_utils.required_interfaces(), expected)