Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using CLI to attach a volume to a VM returns successful even if the operation did not work

By implementation the code for attaching a volume to a VM does not wait to get a respons if the attaching was succeful or not. The user of the CLI gets the device node on which the volume was attached even if the operation of attaching did not succeed. /nova/compute/api.py code _attach_volume calls self.compute_rpcapi.attach_volume(context, instance, volume_bdm) which by implementation does cctxt.cast(ctxt, 'attach_volume', instance=instance, bdm=bdm). Because of using the cast mechanism it will not wait for a reply from the Compute node where the actual work is done, so it will never know if the attachment was succeful, and will inform the CLI user with the expected succeful yaml, according to the Openstack Compute API. RESP BODY: {"volumeAttachment": {"device": "/dev/vdc", "serverId": "04ab7b2d-daf5-4ef7-9266-e90777d5a377", "id": "6589aaef-7d9d-45d5-af0a-a6cdbaca1a7a", "volumeId": "6589aaef-7d9d-45d5-af0a-a6cdbaca1a7a"}}

Proposal:

To use a call instead of a cast and return to the CLI user the right answer, according to what actually happened on the compute node. The downside of this would be that it blocks the console where the CLI command was issued for the time it takes to actually attach the volume on the compute node.

Question: Why a cast is prefered against a call? Did you too in account to use a call and decided that a better way is with cast, and let the user know the device where would be attached the volume if successful?

Many thanks, Andrei Varvara