Return True after success call of update_leader and check return code

This commit is contained in:
Alexander Kukushkin
2015-05-11 08:48:51 +02:00
parent 3a6afe5a9b
commit 588c951a86
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -86,6 +86,7 @@ class Etcd:
def update_leader(self, value):
try:
self.put_client_path("/leader", {"value": value, "ttl": self.ttl, "prevValue": value})
return True
except urllib2.HTTPError:
logger.error("Error updating TTL on ETCD for primary.")
return False
+1 -1
View File
@@ -59,7 +59,7 @@ class Ha:
self.state_handler.follow_the_leader(self.fetch_current_leader())
return "following a different leader because i am not the healthiest node"
else:
if self.has_lock() and self.update_lock()
if self.has_lock() and self.update_lock():
if not self.state_handler.is_leader():
self.state_handler.promote()
return "promoted self to leader because i had the session lock"