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
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2014-10-16 12:36:50 +0000
3+++ hooks/hooks.py 2014-10-20 12:23:33 +0000
4@@ -111,6 +111,8 @@
5 if not haproxy_relations:
6 return None
7 haproxy_relation_units = juju.relation_list(haproxy_relations[0])
8+ if not haproxy_relation_units:
9+ return None
10 haproxy_service = haproxy_relation_units[0].rsplit("/", 1)[0]
11 # jinja2 templates require python-type variables, remove all characters
12 # that do not comply
13
14=== modified file 'hooks/test_hooks.py'
15--- hooks/test_hooks.py 2014-10-16 12:46:35 +0000
16+++ hooks/test_hooks.py 2014-10-20 12:23:33 +0000
17@@ -1600,6 +1600,21 @@
18 haproxy_service_name = hooks._get_haproxy_service_name()
19 self.assertIsNone(haproxy_service_name)
20
21+ def test_no_haproxy_service_name_if_no_units_in_relation(self):
22+ """
23+ _get_haproxy_service_name() returns None if we are related to haproxy,
24+ but that relation has no units.
25+ """
26+ def no_units(relation_id):
27+ return []
28+
29+ self.addCleanup(setattr, hooks.juju, "relation_list",
30+ hooks.juju.relation_list)
31+ hooks.juju.relation_list = no_units
32+ haproxy_service_name = hooks._get_haproxy_service_name()
33+ self.assertIsNone(haproxy_service_name)
34+
35+
36 def test__get_vhost_template(self):
37 """
38 The haproxy prefix in the template variables is replaced by the

Subscribers

People subscribed via source and target branches