From 9379c036d5af4bfe0b35552517b10e994cb54701 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Mon, 30 May 2016 17:02:29 +0200 Subject: [PATCH] Add comments to `set_ttl` method To explain how it's supposed to work and why it manupulates with the cache of `Cluster` object (calls `reset_cluster`) --- patroni/dcs/consul.py | 2 ++ patroni/dcs/etcd.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/patroni/dcs/consul.py b/patroni/dcs/consul.py index 499c8ae1..d20be351 100644 --- a/patroni/dcs/consul.py +++ b/patroni/dcs/consul.py @@ -101,7 +101,9 @@ class Consul(AbstractDCS): except Exception: logger.exception("Can not destroy session %s", self._session) self._session = None + # force `watch` method to call `AbstractDCS.watch` instead of watching for leader key self.reset_cluster() + # fire up an event to wake up from `watch` and immediately run HA loop (to create the new session) self.event.set() self._ttl = ttl diff --git a/patroni/dcs/etcd.py b/patroni/dcs/etcd.py index beb494b5..48afe914 100644 --- a/patroni/dcs/etcd.py +++ b/patroni/dcs/etcd.py @@ -218,7 +218,9 @@ class Etcd(AbstractDCS): def set_ttl(self, ttl): ttl = int(ttl) if self._ttl != ttl: + # force `watch` method to call `AbstractDCS.watch` instead of watching for leader key self.reset_cluster() + # fire up an event to wake up from `watch` and immediately run HA loop (to update TTL of leader and member) self.event.set() self._ttl = ttl