small bug fix i.e previously updating vm['host'] instead of vm['hostname'] + update status of non-stopped vms on dead host to REQUESTED_NEW
This commit is contained in:
parent
3739b299f1
commit
dd3b9fe1cb
1 changed files with 6 additions and 5 deletions
11
main.py
11
main.py
|
@ -80,15 +80,15 @@ def get_suitable_host(etcd_client, vm_prefix, host_prefix, vm_specs):
|
|||
running_vms_specs = [vm[1]["specs"] for vm in vms]
|
||||
# Accumulate all of their combined specs
|
||||
running_vms_accumulated_specs = accumulated_specs(running_vms_specs)
|
||||
print(running_vms_accumulated_specs)
|
||||
# print(running_vms_accumulated_specs)
|
||||
|
||||
# Find out remaining resources after
|
||||
# host_specs - already running vm_specs
|
||||
print(host_value)
|
||||
# print(host_value)
|
||||
remaining = remaining_resources(
|
||||
host_value["specs"], running_vms_accumulated_specs
|
||||
)
|
||||
print(remaining)
|
||||
# print(remaining)
|
||||
# Find out remaining - new_vm_specs
|
||||
remaining = remaining_resources(remaining, vm_specs)
|
||||
# if remaining resources >= 0 return this host_name
|
||||
|
@ -135,8 +135,9 @@ def dead_host_mitigation(client: Etcd3Wrapper, dead_hosts_keys):
|
|||
lambda _vm: _vm.value["hostname"] == host_key, all_vms
|
||||
)
|
||||
for vm in vms_hosted_on_dead_host:
|
||||
vm.value["host"] = ""
|
||||
vm.value["status"] = "REQUESTED_START"
|
||||
vm.value["hostname"] = ""
|
||||
if vm.value["status"] != "STOPPED":
|
||||
vm.value["status"] = "REQUESTED_NEW"
|
||||
client.put(vm.key, vm.value, value_in_json=True)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue