vim_util get_dynamic_property propSet need not be set - makes vmware driver hard to diagnose

Bug #1215958 reported by Shawn Hartsock
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Gary Kotton

Bug Description

It is possible for a query for dynamic_property to find no such property. In this case, propSet on the ObjectContent object will not be 'None' it will not even be set.

def get_dynamic_property(vim, mobj, type, property_name):
    """Gets a particular property of the Managed Object."""
    obj_content = get_object_properties(vim, None, mobj, type, [property_name])
    if hasattr(obj_content, 'token'):
        vim.CancelRetrievePropertiesEx(token=obj_content.token)
    property_value = None
    if obj_content.objects:
        dynamic_property = obj_content.objects[0].propSet
        if dynamic_property:
            property_value = dynamic_property[0].val
    return property_value

Salient docs:
http://pubs.vmware.com/vsphere-51/index.jsp#com.vmware.wssdk.apiref.doc/vmodl.query.PropertyCollector.ObjectContent.html

Trace from ML thread:
> > "/opt/stack/nova/nova/virt/vmwareapi/vim_util.py", line 175, in
> > get_dynamic_property\n dynamic_property =
> > obj_content.objects[0].propSet\n', u"AttributeError: ObjectContent
> > instance has no attribute 'propSet'\n"]

This error will not be a root-cause error, the root cause will be some other misconfiguration but having this particular error in the trace makes diagnostics harder. Fix in such a way that the calling method receives a 'None' or appropriate default return value.

Tags: vmware
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/43665

Changed in nova:
assignee: nobody → Gary Kotton (garyk)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/43665
Committed: http://github.com/openstack/nova/commit/0fb40ceb78c0b35e677b3f2305a6d2477bda0b43
Submitter: Jenkins
Branch: master

commit 0fb40ceb78c0b35e677b3f2305a6d2477bda0b43
Author: Gary Kotton <email address hidden>
Date: Mon Aug 26 01:49:02 2013 -0700

    VMware: Check for the propSet attribute's existence before using

    There may be cases when the call to RetrievePropertiesEx may have missing
    data. That is, the propSet field may be missing. In this case the missing
    field will be logged. This will help with troubleshooting the problem.

    Fields may be missing due to one of the following reasons:
     - SystemError if there was some unknown problem reading the value
     - NoPermission if the logged in session did not have permission to read
       the value

    The propSet attribute is marked as optional in the API documentation so this
    should have been anticipated and this can be interpreted as a bug in the
    client code.

    http://pubs.vmware.com/vsphere-51/index.jsp#com.vmware.wssdk.apiref.doc/vmodl.query.PropertyCollector.ObjectContent.html

    Fixes bug: 1215958

    Change-Id: If8fd912327e057320cd6013c276000617b9c320c

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.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.