EC2: Parse block device mapping incorrectly translates snapshot id

Bug #1089371 reported by Rohit Karajgi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Rohan

Bug Description

Using EC2 API, if a snapshot is used to boot an instance, the code uses the volume UUID
to create the block device mapping.
https://github.com/openstack/nova/blob/master/nova/api/ec2/cloud.py#L134

Due to this, instances cannot be booted from snapshot using EC2.

Rohan (kanaderohan)
Changed in nova:
assignee: nobody → Rohan (kanaderohan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/17933

Changed in nova:
status: New → In Progress
Revision history for this message
Rohit Karajgi (rohitk) wrote :

rohit@ubuntu-precise-152:~/devstack_master$ euca-run-instances -n 1 -t m1.tiny --block-device-mapping /dev/vda=snap-00000002:1:true ami-00000003
VolumeNotFound: Volume vol-00000002 could not be found.

2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] action: RunInstances from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:339
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: BlockDeviceMapping.1.Ebs.SnapshotId val: snap-00000002 from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: BlockDeviceMapping.1.Ebs.DeleteOnTermination val: true from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: ImageId val: ami-00000003 from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: BlockDeviceMapping.1.DeviceName val: /dev/vda from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: BlockDeviceMapping.1.Ebs.VolumeSize val: 1 from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: MaxCount val: 1 from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: MinCount val: 1 from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 DEBUG nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] arg: InstanceType val: m1.tiny from (pid=13117) __call__ /opt/master/nova/nova/api/ec2/__init__.py:341
2012-12-12 05:42:59 INFO nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] VolumeNotFound raised: Volume 2 could not be found.
2012-12-12 05:42:59 ERROR nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] VolumeNotFound: Volume vol-00000002 could not be found.
2012-12-12 05:42:59 INFO nova.api.ec2 [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] 0.27443s 10.2.3.152 POST /services/Cloud/ CloudController:RunInstances 400 [Boto/2.1.1 (linux2)] application/x-www-form-urlencoded text/xml
2012-12-12 05:42:59 INFO nova.ec2.wsgi.server [req-cfeae003-4689-4cda-a769-34e3bc74f767 admin admin] 10.2.3.152 "POST /services/Cloud/ HTTP/1.1" status: 400 len: 333 time: 0.0278509

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/17933
Committed: http://github.com/openstack/nova/commit/4339ecbb4f62a8de5048867262db75f17a8bf5a8
Submitter: Jenkins
Branch: master

commit 4339ecbb4f62a8de5048867262db75f17a8bf5a8
Author: Rohan Rhishikesh Kanade <email address hidden>
Date: Wed Dec 12 05:25:43 2012 -0800

    Fix for correctly parsing snapshot uuid in ec2api

    * EC2 snapshot id correctly translated instead of volume uuid.
    * Add unit tests changes for the existing test.

    Fixes LP Bug #1089371

    Change-Id: Id650ba53dc6cda946531493e3887a01fc5d9bda4

Changed in nova:
status: In Progress → Fix Committed
tags: added: folsom-backport-potential
Changed in nova:
importance: Undecided → Medium
Thierry Carrez (ttx)
Changed in nova:
milestone: none → grizzly-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-2 → 2013.1
Revision history for this message
Zdeněk Pižl (zdenek-pizl) wrote :

there are obvious issue with hardcoded naming templates of volumes and snapshots: vol- and snap-. This error is arising again and again :(

   if ebs:
        ec2_id = ebs.pop('snapshot_id', None)
        if ec2_id:
            snaptpl=FLAGS.snapshot_name_template.split('%')[0]
            volutpl=FLAGS.volume_name_template.split('%')[0]
            if ec2_id.startswith(snaptpl):
               bdm['snapshot_id'] = ec2utils.ec2_snap_id_to_uuid(ec2_id)
            elif ec2_id.startswith(volutpl):
               bdm['volume_id'] = ec2utils.ec2_vol_id_to_uuid(ec2_id)
            ebs.setdefault('delete_on_termination', True)
        bdm.update(ebs)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.