instance_info_cache_update bug if not found

Bug #1131594 reported by Chris Behrens
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Chris Behrens

Bug Description

instance_info_cache_update() in sqlalchemy/api will create an entry if it is found not to exist. However, it creates a very minimal entry and drops potential data that should be added.

        info_cache = model_query(context, models.InstanceInfoCache,
                                 session=session).\
                         filter_by(instance_uuid=instance_uuid).\
                         first()

        if info_cache and not info_cache['deleted']:
            # NOTE(tr3buchet): let's leave it alone if it's already deleted
            info_cache.update(values)
        else:
            # NOTE(tr3buchet): just in case someone blows away an instance's
            # cache entry
            info_cache = models.InstanceInfoCache()
            info_cache.update({'instance_uuid': instance_uuid})

This should be something more like:

  info_cache = model_query(...)
  if info_cache:
      if info_cache['deleted']:
          return
      info_cache.update(values)
  else:
     info_cache = models.InstanceInfoCache()
     values['instance_uuid'] = instance_uuid
     info_cache.update(values)

Chris Behrens (cbehrens)
Changed in nova:
importance: Undecided → Medium
assignee: nobody → Chris Behrens (cbehrens)
milestone: none → grizzly-rc1
status: New → In Progress
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/22860

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

Reviewed: https://review.openstack.org/22860
Committed: http://github.com/openstack/nova/commit/f225b1d20dad1464960dc01243f38924faf4cba9
Submitter: Jenkins
Branch: master

commit f225b1d20dad1464960dc01243f38924faf4cba9
Author: Chris Behrens <email address hidden>
Date: Mon Feb 25 15:39:32 2013 +0000

    instance_info_cache_update creates wrongly

    If instance_info_cache_update() finds that the entry doesn't exist, it
    attempts to create an entry, but it didn't use all of the data. This
    patch fixes that.

    Also if the info_cache entry was found to be deleted, the old code would
    attempt to create a new entry. This would have failed with
    DBDuplicateEntry.. Instead, raise InstanceInfoCacheNotFound, which is
    more appropriate. (It doesn't seem we actually ever hit this case.)

    Fixes bug 1131594

    Change-Id: Id008faf5c4a48ab6a04e75796b7e61dea102acc9

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-rc1 → 2013.1
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.