etcd3_wrapper updated + new timeout event mechanism changes
This commit is contained in:
		
					parent
					
						
							
								b4e19a52e4
							
						
					
				
			
			
				commit
				
					
						b8a44eca69
					
				
			
		
					 2 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -1 +1 @@
 | 
			
		|||
Subproject commit b198048ed81a2113fb4d1fde24d5fcd4b5b614ac
 | 
			
		||||
Subproject commit d079acadf29e6df55c329574604148631d4ad4bc
 | 
			
		||||
							
								
								
									
										9
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue