Merge lp:~ahasenack/landscape-charm/relation-with-no-units into lp:~landscape/landscape-charm/stable

Proposed by Andreas Hasenack
Status: Superseded
Proposed branch: lp:~ahasenack/landscape-charm/relation-with-no-units
Merge into: lp:~landscape/landscape-charm/stable
Diff against target: 38 lines (+17/-0)
2 files modified
hooks/hooks.py (+2/-0)
hooks/test_hooks.py (+15/-0)
To merge this branch: bzr merge lp:~ahasenack/landscape-charm/relation-with-no-units
Reviewer Review Type Date Requested Status
Landscape Pending
Landscape Pending
JuanJo Ciarlante Pending
Review via email: mp+238868@code.launchpad.net

This proposal has been superseded by a proposal from 2014-10-20.

Commit message

Handle the case where the relation with haproxy is established, but there are no units in it yet.

Description of the change

Handle the case where the relation with haproxy is established, but there are no units in it yet.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-10-16 12:36:50 +0000
+++ hooks/hooks.py 2014-10-20 12:23:33 +0000
@@ -111,6 +111,8 @@
111 if not haproxy_relations:111 if not haproxy_relations:
112 return None112 return None
113 haproxy_relation_units = juju.relation_list(haproxy_relations[0])113 haproxy_relation_units = juju.relation_list(haproxy_relations[0])
114 if not haproxy_relation_units:
115 return None
114 haproxy_service = haproxy_relation_units[0].rsplit("/", 1)[0]116 haproxy_service = haproxy_relation_units[0].rsplit("/", 1)[0]
115 # jinja2 templates require python-type variables, remove all characters117 # jinja2 templates require python-type variables, remove all characters
116 # that do not comply118 # that do not comply
117119
=== modified file 'hooks/test_hooks.py'
--- hooks/test_hooks.py 2014-10-16 12:46:35 +0000
+++ hooks/test_hooks.py 2014-10-20 12:23:33 +0000
@@ -1600,6 +1600,21 @@
1600 haproxy_service_name = hooks._get_haproxy_service_name()1600 haproxy_service_name = hooks._get_haproxy_service_name()
1601 self.assertIsNone(haproxy_service_name)1601 self.assertIsNone(haproxy_service_name)
16021602
1603 def test_no_haproxy_service_name_if_no_units_in_relation(self):
1604 """
1605 _get_haproxy_service_name() returns None if we are related to haproxy,
1606 but that relation has no units.
1607 """
1608 def no_units(relation_id):
1609 return []
1610
1611 self.addCleanup(setattr, hooks.juju, "relation_list",
1612 hooks.juju.relation_list)
1613 hooks.juju.relation_list = no_units
1614 haproxy_service_name = hooks._get_haproxy_service_name()
1615 self.assertIsNone(haproxy_service_name)
1616
1617
1603 def test__get_vhost_template(self):1618 def test__get_vhost_template(self):
1604 """1619 """
1605 The haproxy prefix in the template variables is replaced by the1620 The haproxy prefix in the template variables is replaced by the

Subscribers

People subscribed via source and target branches