DescribeInstances does not raise error on invalid instance

Bug #836978 reported by Scott Moser
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Michael Still
devstack
Fix Released
Undecided
Michael Still

Bug Description

DescribeInstances api call doe snot seem to be returning an error on unknown instance id.

against nova:
$ euca-describe-instances i-aaaaaaaa
$ echo $?
0

against ec2:

$ euca-describe-instances i-aaaaaaaa
InvalidInstanceID.NotFound: The instance ID 'i-aaaaaaaa' does not exist
$ echo $?
1

Tags: ec2 ops

Related branches

Revision history for this message
Vish Ishaya (vishvananda) wrote : Re: [Bug 836978] [NEW] DescribeInstances does not raise error on invalid instance

This is due to the way that we check multiple ids and should be an easy fix. While you are at it can you also post what the response should be if there are two ids specified and one exists and the other doesn't?

Brian Waldon (bcwaldon)
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
Changed in nova:
assignee: nobody → Ricardo Carrillo Cruz (rcc)
Changed in nova:
assignee: Ricardo Carrillo Cruz (rcc) → nobody
Revision history for this message
Ricardo Carrillo Cruz (rcarrillocruz) wrote :

Taking, will try to reproduce and work on fix

Changed in nova:
assignee: nobody → Ricardo Carrillo Cruz (rcc)
Revision history for this message
Ricardo Carrillo Cruz (rcarrillocruz) wrote :

I see the problem at _format_instances:

    def _format_instances(self, context, instance_id=None, use_v6=False,
            **search_opts):
        # TODO(termie): this method is poorly named as its name does not imply
        # that it will be making a variety of database calls
        # rather than simply formatting a bunch of instances that
        # were handed to it
        reservations = {}
        # NOTE(vish): instance_id is an optional list of ids to filter by
        if instance_id:
            instances = []
            for ec2_id in instance_id:
                internal_id = ec2utils.ec2_id_to_id(ec2_id)
                try:
                    instance = self.compute_api.get(context, internal_id)
                except exception.NotFound:
                    continue
                instances.append(instance)

If no instance is found wit the ID passed as an argument, the exception is caught but we don´t print anything about it .

Revision history for this message
Ricardo Carrillo Cruz (rcarrillocruz) wrote :

root@openstack-dev:/home/dormammu/src/openstack/nova# euca-describe-instances i-aaaaaaaa
InstanceNotFound: Instance i-aaaaaaaa could not be found.

root@openstack-dev:/home/dormammu/src/openstack/nova# euca-run-instances ami-tiny -t m1.tiny
ImageNotFound: Image ami-tiny could not be found.

root@openstack-dev:/home/dormammu/src/openstack/nova# euca-describe-instances i-aaaaaaaa
InstanceNotFound: Instance i-aaaaaaaa could not be found.

root@openstack-dev:/home/dormammu/src/openstack/nova# euca-run-instances ami-tty -t m1.tiny
RESERVATION r-91huht8j admin default
INSTANCE i-00000001 ami-00000008 pending None (admin, None) 0 m1.tiny 2011-09-21T10:28:16Z unknown zone aki-00000007 ari-00000006

root@openstack-dev:/home/dormammu/src/openstack/nova# euca-describe-instances i-00000001
RESERVATION r-91huht8j admin default
INSTANCE i-00000001 ami-00000008 10.0.0.3 10.0.0.3 running None (admin, openstack-dev) 0 m1.tiny 2011-09-21T10:28:16Z nova aki-00000007 ari-00000006

root@openstack-dev:/home/dormammu/src/openstack/nova# euca-describe-instances i-aaaaaaaa
InstanceNotFound: Instance i-aaaaaaaa could not be found.

Changed in nova:
assignee: Ricardo Carrillo Cruz (rcc) → nobody
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/3978

Changed in nova:
assignee: nobody → Chuck Short (zulcss)
status: Confirmed → In Progress
Revision history for this message
Tom Fifield (fifieldt) wrote :

Review failed and there doesn't look like there's been another fix attempt since.

Changed in nova:
status: In Progress → Confirmed
assignee: Chuck Short (zulcss) → nobody
Michael Still (mikal)
tags: added: ec2 ops
Revision history for this message
Michael Still (mikal) wrote :

I went to write a patch for this, but I can't until I know what to do in the case that two instance ids are passed and one is valid and the other is not. What should happen then?

Revision history for this message
Scott Moser (smoser) wrote :

I ran the attached program with 2 instances running to show what would happen. The short summary:
 If there are invalid instances in the request, do not terminate anything.

Full output:

original: [u'i-2046ba5e/running', u'i-0a46ba74/running']
kill_good_first start: [u'i-2046ba5e/running', u'i-0a46ba74/running']
kill_good_first: killing [u'i-2046ba5e', u'i-11111111']
caught exception
  code=InvalidInstanceID.NotFound
  msg=The instance ID 'i-11111111' does not exist
  reason=Bad Request

kill_good_first end: [u'i-2046ba5e/running', u'i-0a46ba74/running']
kill_bad_first start: [u'i-2046ba5e/running', u'i-0a46ba74/running']
kill_bad_first: killing [u'i-22222222', u'i-0a46ba74']
caught exception
  code=InvalidInstanceID.NotFound
  msg=The instance ID 'i-22222222' does not exist
  reason=Bad Request

kill_bad_first end: [u'i-2046ba5e/running', u'i-0a46ba74/running']

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in nova:
assignee: nobody → Michael Still (mikalstill)
status: Confirmed → In Progress
Revision history for this message
Michael Still (mikal) wrote :

This change of behaviour causes tempest to fail. I need to update the devstack euca exercise.

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

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

Changed in devstack:
assignee: nobody → Michael Still (mikalstill)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to devstack (master)

Reviewed: https://review.openstack.org/18701
Committed: http://github.com/openstack-dev/devstack/commit/796342c06e8ca3dcfd2e8f1ba4e0300a703b8de1
Submitter: Jenkins
Branch: master

commit 796342c06e8ca3dcfd2e8f1ba4e0300a703b8de1
Author: Michael Still <email address hidden>
Date: Fri Dec 28 11:08:20 2012 +1100

    Handle the new behaviour for invalid instances.

    The behaviour of this case changed with bug/836978. Requesting the
    status of an invalid instance will now return an error message
    including the instance id, so we need to filter that out.

    Resolves the devstack elements of bug 836978.

    Change-Id: I385eb6f04cff90e1ddc0b79d835fbbdf92e4e9ff

Changed in devstack:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/18677
Committed: http://github.com/openstack/nova/commit/66d0cb1ce5c9d716ad93685ab6e6e86ddbd0b293
Submitter: Jenkins
Branch: master

commit 66d0cb1ce5c9d716ad93685ab6e6e86ddbd0b293
Author: Michael Still <email address hidden>
Date: Thu Dec 27 16:15:12 2012 +1100

    Invalid EC2 ids should make the entire request fail.

    Resolves bug 836978. I suspect there are many other cases where we
    should add this check.

    Change-Id: I027e44db2e27eb1ef913ddad8560cca08388906b

Changed in nova:
status: In Progress → Fix Committed
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
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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