From cc6811b7f7151c6bef7031859ef24d7efb6eb1d1 Mon Sep 17 00:00:00 2001 From: David Ames Date: Mon, 18 Apr 2016 14:26:52 -0700 Subject: [PATCH] Use restore heat_ prefix for shared-db relation Heat is staying in status blocked Missing relation database when doing an upgrade from stable to next. Missing required data: database_password. The relation is actually passing heat_password. Commit 1bdc87f495898be3a9877f0a14528ce48c27f3f0 removed the heat_ prefix. This changes restores the heat_ prefix to allow stable to next upgrades to work. Change-Id: Id87afd5eda14eceac6c734867f9f96328c116c79 Closes-Bug: #1571830 --- .gitignore | 3 +++ hooks/heat_relations.py | 8 ++++---- hooks/heat_utils.py | 3 ++- tests/basic_deployment.py | 12 ++++++------ unit_tests/test_heat_relations.py | 12 ++++++------ 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 25d8aec..a37185b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ bin tags *.sw[nop] *.pyc +precise/ +trusty/ +xenial/ diff --git a/hooks/heat_relations.py b/hooks/heat_relations.py index 43a1363..fd99591 100755 --- a/hooks/heat_relations.py +++ b/hooks/heat_relations.py @@ -175,9 +175,9 @@ def db_joined(): # NOTE: fallback to private-address host = unit_get('private-address') - relation_set(database=config('database'), - username=config('database-user'), - hostname=host) + relation_set(heat_database=config('database'), + heat_username=config('database-user'), + heat_hostname=host) @hooks.hook('shared-db-relation-changed') @@ -189,7 +189,7 @@ def db_changed(): CONFIGS.write(HEAT_CONF) if is_elected_leader(CLUSTER_RES): - allowed_units = relation_get('allowed_units') + allowed_units = relation_get('heat_allowed_units') if allowed_units and local_unit() in allowed_units.split(): log('Cluster leader, performing db sync') migrate_database() diff --git a/hooks/heat_utils.py b/hooks/heat_utils.py index 8e9e209..f78d392 100644 --- a/hooks/heat_utils.py +++ b/hooks/heat_utils.py @@ -84,7 +84,8 @@ CONFIG_FILES = OrderedDict([ (HEAT_CONF, { 'services': BASE_SERVICES, 'contexts': [context.AMQPContext(ssl_dir=HEAT_DIR), - context.SharedDBContext(ssl_dir=HEAT_DIR), + context.SharedDBContext(relation_prefix='heat', + ssl_dir=HEAT_DIR), context.OSConfigFlagContext(), HeatIdentityServiceContext(service=SVC, service_user=SVC), HeatHAProxyContext(), diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index cc98a2f..7db002d 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -331,9 +331,9 @@ class HeatBasicDeployment(OpenStackAmuletDeployment): relation = ['shared-db', 'mysql:shared-db'] expected = { 'private-address': u.valid_ip, - 'database': 'heat', - 'username': 'heat', - 'hostname': u.valid_ip + 'heat_database': 'heat', + 'heat_username': 'heat', + 'heat_hostname': u.valid_ip } ret = u.validate_relation_data(unit, relation, expected) @@ -349,8 +349,8 @@ class HeatBasicDeployment(OpenStackAmuletDeployment): expected = { 'private-address': u.valid_ip, 'db_host': u.valid_ip, - 'allowed_units': 'heat/0', - 'password': u.not_null + 'heat_allowed_units': 'heat/0', + 'heat_password': u.not_null } ret = u.validate_relation_data(unit, relation, expected) @@ -454,7 +454,7 @@ class HeatBasicDeployment(OpenStackAmuletDeployment): u.log.debug('mysql:heat relation: {}'.format(mysql_rel)) db_uri = "mysql://{}:{}@{}/{}".format('heat', - mysql_rel['password'], + mysql_rel['heat_password'], mysql_rel['db_host'], 'heat') diff --git a/unit_tests/test_heat_relations.py b/unit_tests/test_heat_relations.py index 0a64f5a..22040fa 100644 --- a/unit_tests/test_heat_relations.py +++ b/unit_tests/test_heat_relations.py @@ -113,17 +113,17 @@ class HeatRelationTests(CharmTestCase): self.network_get_primary_address.return_value = '192.168.20.1' self.unit_get.return_value = 'heat.foohost.com' relations.db_joined() - self.relation_set.assert_called_with(database='heat', - username='heat', - hostname='192.168.20.1') + self.relation_set.assert_called_with(heat_database='heat', + heat_username='heat', + heat_hostname='192.168.20.1') self.assertFalse(self.unit_get.called) def test_db_joined(self): self.unit_get.return_value = 'heat.foohost.com' relations.db_joined() - self.relation_set.assert_called_with(database='heat', - username='heat', - hostname='heat.foohost.com') + self.relation_set.assert_called_with(heat_database='heat', + heat_username='heat', + heat_hostname='heat.foohost.com') self.unit_get.assert_called_with('private-address') def _shared_db_test(self, configs):