Merge lp:~cjwatson/launchpad/preflight-standby-counting into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18577
Proposed branch: lp:~cjwatson/launchpad/preflight-standby-counting
Merge into: lp:launchpad
Diff against target: 73 lines (+27/-4)
3 files modified
database/schema/preflight.py (+2/-2)
lib/lp/services/database/postgresql.py (+13/-1)
lib/lp/services/database/tests/test_connectionstring.py (+12/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/preflight-standby-counting
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+341863@code.launchpad.net

Commit message

Merge identical replication standbys for the purposes of preflight checks.

Description of the change

This is because both launchpad_prod_slave1 and launchpad_prod_slave2 are currently pointing at meteor in pgbouncer.

I don't really have a good way to test the preflight part of this, but if it goes wrong (worse than it's already doing in FDTs) then we can always cowboy the one line in preflight.py back to the way it was.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/preflight.py'
2--- database/schema/preflight.py 2014-02-05 05:05:34 +0000
3+++ database/schema/preflight.py 2018-03-22 00:23:41 +0000
4@@ -1,5 +1,5 @@
5 #!/usr/bin/python -S
6-# Copyright 2011-2012 Canonical Ltd. This software is licensed under the
7+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """Confirm the database systems are ready to be patched as best we can."""
11@@ -86,7 +86,7 @@
12 self.lpmain_master_node = node
13
14 # Add streaming replication standbys.
15- standbys = controller.slaves.values()
16+ standbys = set(controller.slaves.values())
17 self._num_standbys = len(standbys)
18 for standby in standbys:
19 standby_node = Node(None, None, standby, False)
20
21=== modified file 'lib/lp/services/database/postgresql.py'
22--- lib/lp/services/database/postgresql.py 2014-01-30 15:04:06 +0000
23+++ lib/lp/services/database/postgresql.py 2018-03-22 00:23:41 +0000
24@@ -1,4 +1,4 @@
25-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
26+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
27 # GNU Affero General Public License version 3 (see the file LICENSE).
28
29 """
30@@ -539,6 +539,18 @@
31 params.append('%s=%s' % (key, val))
32 return ' '.join(params)
33
34+ def __eq__(self, other):
35+ return isinstance(other, ConnectionString) and all(
36+ getattr(self, key, None) == getattr(other, key, None)
37+ for key in self.CONNECTION_KEYS)
38+
39+ def __ne__(self, other):
40+ return not self == other
41+
42+ def __hash__(self):
43+ return hash(
44+ tuple(getattr(self, key, None) for key in self.CONNECTION_KEYS))
45+
46 def asPGCommandLineArgs(self):
47 """Return a string suitable for the PostgreSQL standard tools
48 command line arguments.
49
50=== modified file 'lib/lp/services/database/tests/test_connectionstring.py'
51--- lib/lp/services/database/tests/test_connectionstring.py 2011-12-30 06:14:56 +0000
52+++ lib/lp/services/database/tests/test_connectionstring.py 2018-03-22 00:23:41 +0000
53@@ -1,4 +1,4 @@
54-# Copyright 2011 Canonical Ltd. This software is licensed under the
55+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
56 # GNU Affero General Public License version 3 (see the file LICENSE).
57
58 from lp.services.database.postgresql import ConnectionString
59@@ -38,3 +38,14 @@
60 def test_rejects_quoted_strings(self):
61 self.assertRaises(
62 AssertionError, ConnectionString, "dbname='quoted string'")
63+
64+ def test_equality(self):
65+ cs1 = ConnectionString('dbname=foo host=bar')
66+ cs2 = ConnectionString('dbname=foo host=bar')
67+ cs3 = ConnectionString('dbname=foo host=baz')
68+ self.assertEqual(cs1, cs2)
69+ self.assertNotEqual(cs1, cs3)
70+ self.assertNotEqual(cs2, cs3)
71+ self.assertEqual(hash(cs1), hash(cs2))
72+ self.assertNotEqual(hash(cs1), hash(cs3))
73+ self.assertContentEqual([cs1, cs3], set([cs1, cs2, cs3]))