Merge ~blake-rouse/maas:get-all-rack-conns into maas:master

Proposed by Blake Rouse on 2017-07-18
Status: Merged
Approved by: Andres Rodriguez on 2017-07-18
Approved revision: f5d0d60fa6ea55541356b2cb65ebac8aeb182281
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~blake-rouse/maas:get-all-rack-conns
Merge into: maas:master
Diff against target: 53 lines (+14/-7)
2 files modified
src/maasserver/rpc/regionservice.py (+2/-3)
src/maasserver/rpc/tests/test_regionservice.py (+12/-4)
Reviewer Review Type Date Requested Status
Mike Pontillo (community) 2017-07-18 Approve on 2017-07-18
Review via email: mp+327585@code.launchpad.net

Commit message

Return only one connection per rack controller from getAllClients. Fixes lp: #1704489.

To post a comment you must log in.
Mike Pontillo (mpontillo) wrote :

I think we need to look deeper to check why we have multiple connections to the same rack from a particular region event loop in the first place. But I think this is generally a good change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/rpc/regionservice.py b/src/maasserver/rpc/regionservice.py
2index 8d394cc..a5790e8 100644
3--- a/src/maasserver/rpc/regionservice.py
4+++ b/src/maasserver/rpc/regionservice.py
5@@ -990,11 +990,10 @@ class RegionService(service.Service, object):
6
7 @asynchronous(timeout=FOREVER)
8 def getAllClients(self):
9- """Return a list of all connected :class:`common.Client`s."""
10+ """Return a list with one connection per rack controller."""
11 return [
12- common.Client(conn)
13+ common.Client(random.choice(list(conns)))
14 for conns in self.connections.values()
15- for conn in conns
16 ]
17
18 @asynchronous(timeout=FOREVER)
19diff --git a/src/maasserver/rpc/tests/test_regionservice.py b/src/maasserver/rpc/tests/test_regionservice.py
20index 33b9678..e845b30 100644
21--- a/src/maasserver/rpc/tests/test_regionservice.py
22+++ b/src/maasserver/rpc/tests/test_regionservice.py
23@@ -100,7 +100,9 @@ from testtools.matchers import (
24 Is,
25 IsInstance,
26 MatchesAll,
27+ MatchesAny,
28 MatchesListwise,
29+ MatchesSetwise,
30 MatchesStructure,
31 Not,
32 )
33@@ -884,10 +886,16 @@ class TestRegionService(MAASTestCase):
34 c4 = DummyConnection()
35 service.connections[uuid2].update({c3, c4})
36 clients = service.getAllClients()
37- self.assertItemsEqual(clients, {
38- common.Client(c1), common.Client(c2),
39- common.Client(c3), common.Client(c4),
40- })
41+ self.assertThat(list(clients), MatchesAny(
42+ MatchesSetwise(
43+ Equals(common.Client(c1)), Equals(common.Client(c3))),
44+ MatchesSetwise(
45+ Equals(common.Client(c1)), Equals(common.Client(c4))),
46+ MatchesSetwise(
47+ Equals(common.Client(c2)), Equals(common.Client(c3))),
48+ MatchesSetwise(
49+ Equals(common.Client(c2)), Equals(common.Client(c4))),
50+ ))
51
52 def test_addConnectionFor_adds_connection(self):
53 service = RegionService(sentinel.advertiser)

Subscribers

People subscribed via source and target branches

to all changes: