launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22270
[Merge] lp:~cjwatson/launchpad/preflight-standby-counting into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/preflight-standby-counting into lp:launchpad.
Commit message:
Merge identical replication standbys for the purposes of preflight checks.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/preflight-standby-counting/+merge/341863
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.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/preflight-standby-counting into lp:launchpad.
=== modified file 'database/schema/preflight.py'
--- database/schema/preflight.py 2014-02-05 05:05:34 +0000
+++ database/schema/preflight.py 2018-03-22 00:23:41 +0000
@@ -1,5 +1,5 @@
#!/usr/bin/python -S
-# Copyright 2011-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Confirm the database systems are ready to be patched as best we can."""
@@ -86,7 +86,7 @@
self.lpmain_master_node = node
# Add streaming replication standbys.
- standbys = controller.slaves.values()
+ standbys = set(controller.slaves.values())
self._num_standbys = len(standbys)
for standby in standbys:
standby_node = Node(None, None, standby, False)
=== modified file 'lib/lp/services/database/postgresql.py'
--- lib/lp/services/database/postgresql.py 2014-01-30 15:04:06 +0000
+++ lib/lp/services/database/postgresql.py 2018-03-22 00:23:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""
@@ -539,6 +539,18 @@
params.append('%s=%s' % (key, val))
return ' '.join(params)
+ def __eq__(self, other):
+ return isinstance(other, ConnectionString) and all(
+ getattr(self, key, None) == getattr(other, key, None)
+ for key in self.CONNECTION_KEYS)
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __hash__(self):
+ return hash(
+ tuple(getattr(self, key, None) for key in self.CONNECTION_KEYS))
+
def asPGCommandLineArgs(self):
"""Return a string suitable for the PostgreSQL standard tools
command line arguments.
=== modified file 'lib/lp/services/database/tests/test_connectionstring.py'
--- lib/lp/services/database/tests/test_connectionstring.py 2011-12-30 06:14:56 +0000
+++ lib/lp/services/database/tests/test_connectionstring.py 2018-03-22 00:23:41 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011 Canonical Ltd. This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
from lp.services.database.postgresql import ConnectionString
@@ -38,3 +38,14 @@
def test_rejects_quoted_strings(self):
self.assertRaises(
AssertionError, ConnectionString, "dbname='quoted string'")
+
+ def test_equality(self):
+ cs1 = ConnectionString('dbname=foo host=bar')
+ cs2 = ConnectionString('dbname=foo host=bar')
+ cs3 = ConnectionString('dbname=foo host=baz')
+ self.assertEqual(cs1, cs2)
+ self.assertNotEqual(cs1, cs3)
+ self.assertNotEqual(cs2, cs3)
+ self.assertEqual(hash(cs1), hash(cs2))
+ self.assertNotEqual(hash(cs1), hash(cs3))
+ self.assertContentEqual([cs1, cs3], set([cs1, cs2, cs3]))
Follow ups