From b8a44eca6942e8eae6a7cf119eb47ee180f8b9da Mon Sep 17 00:00:00 2001 From: Ahmad Bilal Khalid Date: Thu, 25 Jul 2019 18:22:40 +0500 Subject: [PATCH] etcd3_wrapper updated + new timeout event mechanism changes --- etcd3_wrapper | 2 +- main.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/etcd3_wrapper b/etcd3_wrapper index b198048..d079aca 160000 --- a/etcd3_wrapper +++ b/etcd3_wrapper @@ -1 +1 @@ -Subproject commit b198048ed81a2113fb4d1fde24d5fcd4b5b614ac +Subproject commit d079acadf29e6df55c329574604148631d4ad4bc diff --git a/main.py b/main.py index 3c3e824..1cf23b9 100644 --- a/main.py +++ b/main.py @@ -58,10 +58,6 @@ logging.basicConfig( def goodbye(host): - host.value["status"] = "DEAD" - host.value["last_heartbeat"] = datetime.utcnow().isoformat() - client.put(host.key, json.dumps(host.value)) - vms = client.get_prefix("/v1/vm", value_in_json=True) vms = filter(lambda v: v.value["hostname"] == host.key, vms) for vm in vms: @@ -72,6 +68,10 @@ def goodbye(host): client.put(vm.key, vm.value, value_in_json=True) + host.value["status"] = "DEAD" + host.value["last_heartbeat"] = datetime.utcnow().isoformat() + client.put(host.key, json.dumps(host.value)) + logging.info(f"Host {host.key} dead! at {host.value['last_heartbeat']}") print("Goodbye") os.kill(os.getpid(), signal.SIGKILL) @@ -290,6 +290,7 @@ def main(): e_status = e.value["status"] if e_status == "TIMEOUT": + client.client.delete(e.key) logging.info("Timeout") maintenence(e, host) continue