From 5f65b56045bf6de58de7ea97c431f109703b7620 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Mon, 11 Sep 2023 15:15:32 +0200 Subject: [PATCH] more f-strings --- patroni/quorum.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/patroni/quorum.py b/patroni/quorum.py index c510cfca..5c85bd47 100644 --- a/patroni/quorum.py +++ b/patroni/quorum.py @@ -154,13 +154,15 @@ class QuorumStateResolver: # with any subset of nodes that can achieve quorum to promote a new leader. # ``+ 1`` is required because the leader is included in the set. if self.voters and not (len(voters | sync) <= self.quorum + self.numsync + 1): - raise QuorumError("Quorum and sync not guaranteed to overlap: nodes %d >= quorum %d + sync %d" % - (len(voters | sync), self.quorum, self.numsync)) + len_nodes = len(voters | sync) + raise QuorumError("Quorum and sync not guaranteed to overlap: " + f"nodes {len_nodes} >= quorum {self.quorum} + sync {self.sync} + 1") # unstable cases, we are changing synchronous_standby_names and /sync key # one after another, hence one set is allowed to be a subset of another if not (voters.issubset(sync) or sync.issubset(voters)): - raise QuorumError("Mismatched sets: quorum only=%s sync only=%s" % - (voters - sync, sync - voters)) + voters_only = voters - sync + sync_only = sync - voters + raise QuorumError(f"Mismatched sets: voter only={voters_only} sync only={sync_only}") def quorum_update(self, quorum: int, voters: CaseInsensitiveSet, leader: Optional[str] = None, adjust_quorum: Optional[bool] = True) -> Iterator[Transition]: