← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1226083] Re: extract_flavor() doesn't work for deleted instances

 

** Changed in: nova
       Status: Fix Committed => Fix Released

** Changed in: nova
    Milestone: None => kilo-rc1

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1226083

Title:
  extract_flavor() doesn't work for deleted instances

Status in OpenStack Compute (Nova):
  Fix Released

Bug description:
  If instance_sys_meta() can be called for instances which are deleted,
  and  instance'[system_metatdata'] is a list it will return an empty
  dict, as metadata_to_dict() skips deleted entries:

   
  def metadata_to_dict(metadata):
      result = {}
      for item in metadata:
          if not item.get('deleted'):
              result[item['key']] = item['value']
      return result

  
  The path that lead to this discovery was sending a notification message for a deleted instance, which has been fixed by a separate change, so its not clear if this issue still needs to be fixed.   The following code does provide a fix, but returns all deleted metadata items, not just those that existed at the time the instance was deleted:

   def metadata_to_dict(metadata, skip_deleted=True):
      result = {}
      for item in metadata:
          if not item.get('deleted') or not skip_deleted:
              result[item['key']] = item['value']
      return result

  def instance_meta(instance):
      if isinstance(instance['metadata'], dict):
          return instance['metadata']
      else:
          return metadata_to_dict(instance['metadata'],
                                  instance['deleted']==0)

  
  def instance_sys_meta(instance):

      if isinstance(instance['system_metadata'], dict):
          return instance['system_metadata']
      else:
          return metadata_to_dict(instance['system_metadata'],
                                  instance['deleted']==0)

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1226083/+subscriptions