Commit 6b9f1b3f authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Fix bug in handling of reboot type.

'type' attribute of reboot OS API call was directly mapped to the
'reboot_type' option of Ganeti reboot job. However these two are
semantically different. The 'SOFT' and 'HARD' reboot types of OS API are
mapped to 'shutdown_timeout' option of Ganeti jobs. However, setting
this option from Ganeti RAPI is not supported. Until implemented, we
will map both types to 'hard' ganeti reboot, and fallback to default
shutdown timeout of Ganeti (120s).

Also, modify UI to not set the 'HARD' reboot type and fallback to
default option of API which is 'SOFT'.
parent 4cd4ab12
......@@ -733,10 +733,8 @@ def reboot(request, vm, args):
# buildInProgress (409),
# overLimit (413)
reboot_type = args.get("type")
if reboot_type is None:
raise faults.BadRequest("Missing 'type' attribute.")
elif reboot_type not in ["SOFT", "HARD"]:
reboot_type = args.get("type", "SOFT")
if reboot_type not in ["SOFT", "HARD"]:
raise faults.BadRequest("Invalid 'type' attribute.")
vm = servers.reboot(vm, reboot_type=reboot_type)
return HttpResponse(status=202)
......
......@@ -572,9 +572,20 @@ def delete_instance(vm):
def reboot_instance(vm, reboot_type):
assert reboot_type in ('soft', 'hard')
kwargs = {"instance": vm.backend_vm_id,
"reboot_type": "hard"}
# XXX: Currently shutdown_timeout parameter is not supported from the
# Ganeti RAPI. Until supported, we will fallback for both reboot types
# to the default shutdown timeout of Ganeti (120s). Note that reboot
# type of Ganeti job must be always hard. The 'soft' and 'hard' type
# of OS API is different from the one in Ganeti, and maps to
# 'shutdown_timeout'.
#if reboot_type == "hard":
# kwargs["shutdown_timeout"] = 0
if settings.TEST:
kwargs["dry_run"] = True
with pooled_rapi_client(vm) as client:
return client.RebootInstance(vm.backend_vm_id, reboot_type,
dry_run=settings.TEST)
return client.RebootInstance(**kwargs)
def startup_instance(vm):
......
......@@ -1438,7 +1438,7 @@
case 'reboot':
this.__make_api_call(this.get_action_url(), // vm actions url
"create", // create so that sync later uses POST to make the call
{reboot:{type:"HARD"}}, // payload
{reboot:{}}, // payload
function() {
// set state after successful call
self.state("REBOOT");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment