From f45e5edeed8ebfd9c73b479a779ce3160250ee7b Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 21 Dec 2017 11:49:02 +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: Ia197a37cbfe9c11538f272437d95cfc836768cc9 --- hooks/glance_relations.py | 51 ----------------- hooks/glance_utils.py | 4 +- hooks/pgsql-db-relation-broken | 1 - hooks/pgsql-db-relation-changed | 1 - hooks/pgsql-db-relation-joined | 1 - metadata.yaml | 2 - unit_tests/test_glance_relations.py | 88 ----------------------------- 7 files changed, 1 insertion(+), 147 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/glance_relations.py b/hooks/glance_relations.py index 9a0bc11c..3a423fb7 100755 --- a/hooks/glance_relations.py +++ b/hooks/glance_relations.py @@ -48,10 +48,8 @@ from charmhelpers.core.hookenv import ( Hooks, log as juju_log, DEBUG, - ERROR, WARNING, open_port, - is_relation_made, local_unit, relation_get, relation_set, @@ -148,13 +146,6 @@ def install_hook(): @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') - juju_log(e, level=ERROR) - raise Exception(e) - if config('prefer-ipv6'): sync_db_with_multi_ipv6_addresses(config('database'), config('database-user')) @@ -173,18 +164,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') - juju_log(e, level=ERROR) - raise Exception(e) - - relation_set(database=config('database')) - - @hooks.hook('shared-db-relation-changed') @restart_on_change(restart_map()) def db_changed(): @@ -222,35 +201,6 @@ def db_changed(): image_service_joined(rid) -@hooks.hook('pgsql-db-relation-changed') -@restart_on_change(restart_map()) -def pgsql_db_changed(): - rel = os_release('glance-common') - - if 'pgsql-db' not in CONFIGS.complete_contexts(): - juju_log('pgsql-db relation incomplete. Peer not ready?') - return - - CONFIGS.write(GLANCE_REGISTRY_CONF) - # since folsom, a db connection setting in glance-api.conf is required. - if rel != "essex": - CONFIGS.write(GLANCE_API_CONF) - - if is_elected_leader(CLUSTER_RES): - if rel == "essex": - status = call(['glance-manage', 'db_version']) - if status != 0: - juju_log('Setting version_control to 0') - cmd = ["glance-manage", "version_control", "0"] - check_call(cmd) - - juju_log('Cluster leader, performing db sync') - migrate_database() - - for rid in relation_ids('image-service'): - image_service_joined(rid) - - @hooks.hook('image-service-relation-joined') def image_service_joined(relation_id=None): relation_data = { @@ -553,7 +503,6 @@ def ha_relation_changed(): @hooks.hook('identity-service-relation-broken', 'object-store-relation-broken', 'shared-db-relation-broken', - 'pgsql-db-relation-broken', 'cinder-volume-service-relation-broken', 'storage-backend-relation-broken') def relation_broken(): diff --git a/hooks/glance_utils.py b/hooks/glance_utils.py index 837f2b41..cbee39e1 100644 --- a/hooks/glance_utils.py +++ b/hooks/glance_utils.py @@ -160,7 +160,7 @@ TEMPLATES = 'templates/' # The interface is said to be satisfied if anyone of the interfaces in the # list has a complete context. REQUIRED_INTERFACES = { - 'database': ['shared-db', 'pgsql-db'], + 'database': ['shared-db'], 'identity': ['identity-service'], } @@ -171,7 +171,6 @@ def ceph_config_file(): CONFIG_FILES = OrderedDict([ (GLANCE_REGISTRY_CONF, { 'hook_contexts': [context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), - context.PostgresqlDBContext(), context.IdentityServiceContext( service='glance', service_user='glance'), @@ -188,7 +187,6 @@ CONFIG_FILES = OrderedDict([ (GLANCE_API_CONF, { 'hook_contexts': [context.SharedDBContext(ssl_dir=GLANCE_CONF_DIR), context.AMQPContext(ssl_dir=GLANCE_CONF_DIR), - context.PostgresqlDBContext(), context.IdentityServiceContext( service='glance', service_user='glance'), diff --git a/hooks/pgsql-db-relation-broken b/hooks/pgsql-db-relation-broken deleted file mode 120000 index e955ca43..00000000 --- a/hooks/pgsql-db-relation-broken +++ /dev/null @@ -1 +0,0 @@ -glance_relations.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 e955ca43..00000000 --- a/hooks/pgsql-db-relation-changed +++ /dev/null @@ -1 +0,0 @@ -glance_relations.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 e955ca43..00000000 --- a/hooks/pgsql-db-relation-joined +++ /dev/null @@ -1 +0,0 @@ -glance_relations.py \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index a046d294..6054b280 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -28,8 +28,6 @@ provides: requires: shared-db: interface: mysql-shared - pgsql-db: - interface: pgsql amqp: interface: rabbitmq optional: true diff --git a/unit_tests/test_glance_relations.py b/unit_tests/test_glance_relations.py index f29c3e2f..d033013a 100644 --- a/unit_tests/test_glance_relations.py +++ b/unit_tests/test_glance_relations.py @@ -53,7 +53,6 @@ TO_PATCH = [ 'Hooks', 'config', 'juju_log', - 'is_relation_made', 'local_unit', 'open_port', 'relation_ids', @@ -178,36 +177,12 @@ class GlanceRelationTests(CharmTestCase): def test_db_joined(self): self.get_relation_ip.return_value = '10.0.0.1' - self.is_relation_made.return_value = False relations.db_joined() self.relation_set.assert_called_with(database='glance', username='glance', hostname='10.0.0.1') self.get_relation_ip.assert_called_with('shared-db', cidr_network=None) - def test_postgresql_db_joined(self): - self.is_relation_made.return_value = False - relations.pgsql_db_joined() - self.relation_set.assert_called_with(database='glance'), - - def test_db_joined_with_postgresql(self): - self.is_relation_made.return_value = True - - with self.assertRaises(Exception) as context: - relations.db_joined() - self.assertEqual(context.exception.message, - 'Attempting to associate a mysql database when there ' - 'is already associated a postgresql one') - - def test_postgresql_joined_with_db(self): - self.is_relation_made.return_value = True - - with self.assertRaises(Exception) as context: - relations.pgsql_db_joined() - self.assertEqual(context.exception.message, - 'Attempting to associate a postgresql database when' - ' there is already associated a mysql one') - @patch.object(relations, 'CONFIGS') def test_db_changed_missing_relation_data(self, configs): configs.complete_contexts = MagicMock() @@ -217,15 +192,6 @@ class GlanceRelationTests(CharmTestCase): 'shared-db relation incomplete. Peer not ready?' ) - @patch.object(relations, 'CONFIGS') - def test_postgresql_db_changed_missing_relation_data(self, configs): - configs.complete_contexts = MagicMock() - configs.complete_contexts.return_value = [] - relations.pgsql_db_changed() - self.juju_log.assert_called_with( - 'pgsql-db relation incomplete. Peer not ready?' - ) - def _shared_db_test(self, configs, unit_name, allowed_units='glance/0 glance/3'): self.relation_get.return_value = allowed_units @@ -235,12 +201,6 @@ class GlanceRelationTests(CharmTestCase): configs.write = MagicMock() relations.db_changed() - def _postgresql_db_test(self, configs): - configs.complete_contexts = MagicMock() - configs.complete_contexts.return_value = ['pgsql-db'] - configs.write = MagicMock() - relations.pgsql_db_changed() - @patch.object(relations, 'CONFIGS') def test_db_changed_allowed(self, configs): self._shared_db_test(configs, 'glance/0') @@ -276,17 +236,6 @@ class GlanceRelationTests(CharmTestCase): self._shared_db_test(configs, 'glance/2', None) [self.assertIn(call(r), imgsj.call_args_list) for r in rids] - @patch.object(relations, 'CONFIGS') - def test_postgresql_db_changed_no_essex(self, configs): - self._postgresql_db_test(configs) - self.assertEqual([call('/etc/glance/glance-registry.conf'), - call('/etc/glance/glance-api.conf')], - configs.write.call_args_list) - self.juju_log.assert_called_with( - 'Cluster leader, performing db sync' - ) - self.migrate_database.assert_called_with() - @patch.object(relations, 'CONFIGS') def test_db_changed_with_essex_not_setting_version_control(self, configs): self.os_release.return_value = "essex" @@ -299,27 +248,6 @@ class GlanceRelationTests(CharmTestCase): ) self.migrate_database.assert_called_with() - @patch.object(relations, 'CONFIGS') - def test_postgresql_db_changed_with_essex_not_setting_version_control( - self, configs): - self.os_release.return_value = "essex" - self.call.return_value = 0 - self._postgresql_db_test(configs) - self.assertEqual([call('/etc/glance/glance-registry.conf')], - configs.write.call_args_list) - self.juju_log.assert_called_with( - 'Cluster leader, performing db sync' - ) - self.migrate_database.assert_called_with() - - @patch.object(relations, 'image_service_joined') - @patch.object(relations, 'CONFIGS') - def test_postgresql_db_changed_image_service_joined(self, configs, imgsj): - rids = ['nova-cloud-controller:1', 'nova-compute:1'] - self.relation_ids.return_value = rids - self._postgresql_db_test(configs) - [self.assertIn(call(r), imgsj.call_args_list) for r in rids] - @patch.object(relations, 'CONFIGS') def test_db_changed_with_essex_setting_version_control(self, configs): self.os_release.return_value = "essex" @@ -335,22 +263,6 @@ class GlanceRelationTests(CharmTestCase): ) self.migrate_database.assert_called_with() - @patch.object(relations, 'CONFIGS') - def test_postgresql_db_changed_with_essex_setting_version_control( - self, configs): - self.os_release.return_value = "essex" - self.call.return_value = 1 - self._postgresql_db_test(configs) - self.assertEqual([call('/etc/glance/glance-registry.conf')], - configs.write.call_args_list) - self.check_call.assert_called_with( - ["glance-manage", "version_control", "0"] - ) - self.juju_log.assert_called_with( - 'Cluster leader, performing db sync' - ) - self.migrate_database.assert_called_with() - @patch.object(relations, 'is_api_ready') @patch.object(relations, 'canonical_url') def test_image_service_joined_leader(self, _canonical_url, _api_ready):