Merge lp:~dpb/juju-deployer/lxc-placement-fix into lp:juju-deployer

Proposed by David Britton
Status: Merged
Merged at revision: 120
Proposed branch: lp:~dpb/juju-deployer/lxc-placement-fix
Merge into: lp:juju-deployer
Prerequisite: lp:~dpb/juju-deployer/api-endpoints
Diff against target: 55 lines (+16/-4)
3 files modified
deployer/service.py (+4/-3)
deployer/tests/test_data/stack-placement.yaml (+4/-0)
deployer/tests/test_deployment.py (+8/-1)
To merge this branch: bzr merge lp:~dpb/juju-deployer/lxc-placement-fix
Reviewer Review Type Date Requested Status
Kapil Thangavelu Approve
Review via email: mp+230924@code.launchpad.net

Description of the change

I'm pretty sure a simple variable error/typo caused this bug. The fall-through behavior of the routine was correct, but an early exit was checking the wrong variable making the default placement algorithm take over too soon.

I changed the variable being tested and cleaned up the warning message a bit. I also added a unit test for this case (which runs and fails on the old code)

To post a comment you must log in.
125. By David Britton

typo in log print

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

Thanks, merged

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/service.py'
2--- deployer/service.py 2014-06-19 12:30:44 +0000
3+++ deployer/service.py 2014-08-15 21:05:19 +0000
4@@ -139,10 +139,11 @@
5 return None
6
7 svc_units = with_service['units']
8- if len(svc_units) <= unit_number:
9+ if int(u_idx) >= len(svc_units):
10 self.deployment.log.warning(
11- "Service:%s deploy-with Service:%s, but no with unit found",
12- svc.name, placement)
13+ "Service:%s, Deploy-with-service:%s, Requested-unit-index=%s, "
14+ "Cannot solve, falling back to default placement",
15+ svc.name, placement, u_idx)
16 return None
17 unit_names = svc_units.keys()
18 unit_names.sort()
19
20=== modified file 'deployer/tests/test_data/stack-placement.yaml'
21--- deployer/tests/test_data/stack-placement.yaml 2013-10-31 19:19:36 +0000
22+++ deployer/tests/test_data/stack-placement.yaml 2014-08-15 21:05:19 +0000
23@@ -16,3 +16,7 @@
24 to: lxc:nova-compute=2
25 semper:
26 to: nova-compute=2
27+ lxc-service:
28+ # Ensure more than nova-compute, catches lp:1357196
29+ num_units: 5
30+ to: [ "lxc:nova-compute=1", "lxc:nova-compute=2", "lxc:nova-compute=0", "lxc:nova-compute=0", "lxc:nova-compute=2" ]
31
32=== modified file 'deployer/tests/test_deployment.py'
33--- deployer/tests/test_deployment.py 2014-02-18 14:33:13 +0000
34+++ deployer/tests/test_deployment.py 2014-08-15 21:05:19 +0000
35@@ -119,6 +119,13 @@
36 placement = d.get_unit_placement('semper', status)
37 self.assertEqual(placement.get(0), '3')
38
39+ placement = d.get_unit_placement('lxc-service', status)
40+ self.assertEqual(placement.get(0), 'lxc:2')
41+ self.assertEqual(placement.get(1), 'lxc:3')
42+ self.assertEqual(placement.get(2), 'lxc:1')
43+ self.assertEqual(placement.get(3), 'lxc:1')
44+ self.assertEqual(placement.get(4), 'lxc:3')
45+
46 def test_multiple_relations_no_weight(self):
47 data = {"relations": {"wordpress": {"consumes": ["mysql"]},
48 "nginx": {"consumes": ["wordpress"]}}}
49@@ -154,5 +161,5 @@
50 deployment = self.get_named_deployment("stack-placement.yaml", "stack")
51 service_names = deployment.get_service_names()
52 expected_service_names = [
53- 'ceph', 'mysql', 'nova-compute', 'quantum', 'semper', 'verity']
54+ 'ceph', 'mysql', 'nova-compute', 'quantum', 'semper', 'verity', 'lxc-service']
55 self.assertEqual(set(expected_service_names), set(service_names))

Subscribers

People subscribed via source and target branches