ZAPI-782: ZAPI-685 broke DeleteVm

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2017-04-27T17:51:12.000Z)

Fix Versions

2017-04-27 PACT MEDIUM (Release Date: 2017-04-27)

Related Links

Description

Changes in ZAPI-685 broke the DeleteVm endpoint in several ways:

1. It caused SAPI-286 by introducing an inconsistent response's data structure: it would respond with an object that would not be of the form: {"vm_uuid": "some-uuid", "job_uuid": "some-other-uuid"}

2. It caused ZAPI-755, where a VM stuck in a provisioning state could never be deleted, even if it had a server_uuid

We should do the following things in order to fix these two issues:

1. Do not error if a VM is in state 'provisioning' but has a server_uuid}}, because in this case the destroy workflow has a chance to actually delete the VM. This would fix ZAPI-755 for VMs with a server_uuid}}. VMs stuck in 'provisioning'}} state without a server_uuid}} would still not be deletable, but that was the case before ZAPI-685.

2. When a VM has no server_uuid, regardless of its state, we should error instead of marking it as destroyed, as there is currently no way for VMAPI to determine whether there is an actual instance on a CN that corresponds to that vm_uuid (there could be one, or there could be none). What would have happened before is that a workflow job would have been started, but it would always fail because it would send a HTTP request to an endpoint that is not handled (job.params\['server_uuid'\ would not be a valid server_uuid)|https://github.com/joyent/sdc-vmapi/blob/e4cfd962384a45038ad823ab197ca9b375d7d94b/lib/workflows/destroy.js#L30-L32], so there would be no regression for this use case.

3. Do not check whether or not the VM's server_uuid refers to an available CN or not. Regardless, trigger a workflow and let the workflow error or set the VM's state to destroyed itself. Marking the VM as destroyed without starting a workflow would require the response object sent to VMAPI clients to have a job_uuid property set to null, which was a breaking change.

Comments

Comment by Bot Bot [X]
Created at 2017-04-26T21:39:16.000Z

sdc-vmapi commit f820739 (branch master, by Julien Gilli)

ZAPI-782 ZAPI-685 broke DeleteVm
    Reviewed by: Trent Mick <trent.mick@joyent.com>
    Approved by: Trent Mick <trent.mick@joyent.com>


Comment by Bot Bot [X]
Created at 2017-04-28T17:00:08.000Z

sdc-vm-agent commit d9f8188 (branch master, by Josh Wilsdon)

AGENT-1070 ZAPI-782 broke cn-agent tests