etcd3_wrapper updated + new timeout event mechanism changes

This commit is contained in:
ahmadbilalkhalid 2019-07-25 18:22:40 +05:00
parent b4e19a52e4
commit b8a44eca69
2 changed files with 6 additions and 5 deletions

@ -1 +1 @@
Subproject commit b198048ed81a2113fb4d1fde24d5fcd4b5b614ac Subproject commit d079acadf29e6df55c329574604148631d4ad4bc

View file

@ -58,10 +58,6 @@ logging.basicConfig(
def goodbye(host): 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 = client.get_prefix("/v1/vm", value_in_json=True)
vms = filter(lambda v: v.value["hostname"] == host.key, vms) vms = filter(lambda v: v.value["hostname"] == host.key, vms)
for vm in vms: for vm in vms:
@ -72,6 +68,10 @@ def goodbye(host):
client.put(vm.key, vm.value, value_in_json=True) 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']}") logging.info(f"Host {host.key} dead! at {host.value['last_heartbeat']}")
print("Goodbye") print("Goodbye")
os.kill(os.getpid(), signal.SIGKILL) os.kill(os.getpid(), signal.SIGKILL)
@ -290,6 +290,7 @@ def main():
e_status = e.value["status"] e_status = e.value["status"]
if e_status == "TIMEOUT": if e_status == "TIMEOUT":
client.client.delete(e.key)
logging.info("Timeout") logging.info("Timeout")
maintenence(e, host) maintenence(e, host)
continue continue