ZAPI-687: putVm blocks calls for new VMs inappropriately.

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2015-11-30T19:36:14.000Z)

Fix Versions

2015-12-10 Dino (Release Date: 2015-10-12)

Description

TL;DR; Calling loadVm before processing `PUT /vms/:uuid:` disallows a PUT request for a VM that doesn't exist in VMAPI yet. This breaks `vmadm create` functionality. We need to move away from the interceptors.js anti-pattern.

----

Because `putvm` is no longer in the skipRoutes array, loadVm will be loaded whenever a call to `PUT /vms/:uuid:` is made. This behavior is okay, except in the case where a VM exists on a CN but not yet in VMAPI's VM Moray bucket. This scenario exists when an operator creates a VM with vmadm.

The loadVm function responds with a 404 and short circuits the PUT request if VMAPI doesn't have the given UUID in its Moray bucket. It will also respond with an 4XX error if the user making the request is not the owner of the VM.

The PUT methods in VMAPI are admin / system routes only and never intended to be used outside the control plane. The loadVm functionality is necessary for these methods, but it should not enforce non-operator criteria on the control plane.

Lastly, the interceptors.js code is a bit of an anti-pattern because it applies somewhat specific code broadly to all the things. Because ZAPI-662 and ZAPI-655 require the loadVm functionality, I suggest we start moving away from the interceptors.js code and use specific handlers as a part of putVm and putVMs.

cc: @josh, @julien.gilli

Comments

Comment by Bot Bot [X]
Created at 2015-11-27T05:40:10.000Z

sdc-vmapi commit 58f775d (branch master, by Richard Kiene)

ZAPI-662: Add changefeed support
    ZAPI-684: Replace common.objectDiff with deep-diff
    ZAPI-687: Allow VM creation via PUT /vms


Comment by Bot Bot [X]
Created at 2015-11-27T19:38:28.000Z

sdc-vmapi commit 4461eab (branch master, by Josh Wilsdon)

ZAPI-662: Add changefeed support (needs more work)
    ZAPI-684: Replace common.objectDiff with deep-diff (needs more work)
    ZAPI-687: Allow VM creation via PUT /vms (needs more work)


Comment by Bot Bot [X]
Created at 2015-11-28T08:39:05.000Z

sdc-vmapi commit 92e4682 (branch master, by Richard Kiene)

ZAPI-662: Add changefeed support
    ZAPI-684: Replace common.objectDiff with deep-diff
    ZAPI-687: Allow VM creation via PUT /vms


Comment by Richard Kiene
Created at 2015-11-30T19:36:14.000Z
This was fixed as a part of the ZAPI-662 work.