← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1294509] [NEW] NoneType is returned from libvirt while get_vcpu_used

 

Public bug reported:

169568 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
169569 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] File "/usr/lib/python2.7/dist-packages/nova/network/manager.py", line 1031, in allocate_fixed_ip
169570 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] self.add_fixed_ip_to_ipset(context, address, tenant_id)
169571 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
169572 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] File "/usr/lib/python2.7/dist-packages/nova/network/manager.py", line 896, in add_fixed_ip_to_ipset
169573 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] tenant_id = fixed_ip_ref.instance['project_id']
169574 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
169575 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] TypeError: 'NoneType' object has no attribute '__getitem__'
169576 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
169577 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 

this because of my commit as below, 
Reviewed: https://review.openstack.org/67361
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=844df860c38ac38550b8d1739fd53131cd7fd864
Submitter: Jenkins
Branch: master

commit 844df860c38ac38550b8d1739fd53131cd7fd864
Author: Wangpan <hzwangpan@xxxxxxxxxxxxxxxx>
Date: Fri Jan 17 10:35:12 2014 +0800

    libvirt: handle exception while get vcpu info

    If an exception is raised while get a libvirt domain's vcpu info,
    the update_available_resource periodic task will be failed, which
    will result in the resource of this compute node will never be
    reported.

    This patch add an exception handling to avoid this situation.
    Closes-bug: #1270008

the checking of return value is None was removed, but old python-libvirt(e.g. 0.9.x) only raise libvirtError while the libvirt api return -1, and the old libvirt return None rather than -1 while get vcpu info failed, please see the libvirt codes below:
python/libvirt-override.c:
static PyObject *                                                                   
libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,                          
                          PyObject *args) {                                         
    virDomainPtr domain;                                                            
    PyObject *pyobj_domain, *pyretval = NULL, *pycpuinfo = NULL, *pycpumap = NULL;
    virNodeInfo nodeinfo;                                                           
    virDomainInfo dominfo;                                                          
    virVcpuInfoPtr cpuinfo = NULL;                                                  
    unsigned char *cpumap = NULL;                                                   
    size_t cpumaplen, i;                                                            
    int i_retval;                                                                   
                                                                                    
    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetVcpus",                      
                          &pyobj_domain))                                           
        return NULL;                                                                
    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);                          
                                                                                    
    LIBVIRT_BEGIN_ALLOW_THREADS;                                                    
    i_retval = virNodeGetInfo(virDomainGetConnect(domain), &nodeinfo);              
    LIBVIRT_END_ALLOW_THREADS;                                                      
    if (i_retval < 0)                                                               
        return VIR_PY_NONE;                                                         
                                                                                    
    LIBVIRT_BEGIN_ALLOW_THREADS;                                                    
    i_retval = virDomainGetInfo(domain, &dominfo);                                  
    LIBVIRT_END_ALLOW_THREADS;                                                      
    if (i_retval < 0)                                                               
        return VIR_PY_NONE;                                                         
                                                                                    
    if (VIR_ALLOC_N(cpuinfo, dominfo.nrVirtCpu) < 0)                                
        return VIR_PY_NONE;

so we should add the None type checking to libvirt driver for the
compatibility of old libvirt.

** Affects: nova
     Importance: Undecided
         Status: New

-- 
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/1294509

Title:
  NoneType is returned from libvirt while get_vcpu_used

Status in OpenStack Compute (Nova):
  New

Bug description:
  169568 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
  169569 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] File "/usr/lib/python2.7/dist-packages/nova/network/manager.py", line 1031, in allocate_fixed_ip
  169570 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] self.add_fixed_ip_to_ipset(context, address, tenant_id)
  169571 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
  169572 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] File "/usr/lib/python2.7/dist-packages/nova/network/manager.py", line 896, in add_fixed_ip_to_ipset
  169573 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] tenant_id = fixed_ip_ref.instance['project_id']
  169574 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
  169575 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] TypeError: 'NoneType' object has no attribute '__getitem__'
  169576 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 
  169577 2014-03-19 14:46:35.193 43907 TRACE nova.compute.manager [instance: 94518175-a4ad-4b5c-be76-3888b09810b4] 

  this because of my commit as below, 
  Reviewed: https://review.openstack.org/67361
  Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=844df860c38ac38550b8d1739fd53131cd7fd864
  Submitter: Jenkins
  Branch: master

  commit 844df860c38ac38550b8d1739fd53131cd7fd864
  Author: Wangpan <hzwangpan@xxxxxxxxxxxxxxxx>
  Date: Fri Jan 17 10:35:12 2014 +0800

      libvirt: handle exception while get vcpu info

      If an exception is raised while get a libvirt domain's vcpu info,
      the update_available_resource periodic task will be failed, which
      will result in the resource of this compute node will never be
      reported.

      This patch add an exception handling to avoid this situation.
      Closes-bug: #1270008

  the checking of return value is None was removed, but old python-libvirt(e.g. 0.9.x) only raise libvirtError while the libvirt api return -1, and the old libvirt return None rather than -1 while get vcpu info failed, please see the libvirt codes below:
  python/libvirt-override.c:
  static PyObject *                                                                   
  libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,                          
                            PyObject *args) {                                         
      virDomainPtr domain;                                                            
      PyObject *pyobj_domain, *pyretval = NULL, *pycpuinfo = NULL, *pycpumap = NULL;
      virNodeInfo nodeinfo;                                                           
      virDomainInfo dominfo;                                                          
      virVcpuInfoPtr cpuinfo = NULL;                                                  
      unsigned char *cpumap = NULL;                                                   
      size_t cpumaplen, i;                                                            
      int i_retval;                                                                   
                                                                                      
      if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetVcpus",                      
                            &pyobj_domain))                                           
          return NULL;                                                                
      domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);                          
                                                                                      
      LIBVIRT_BEGIN_ALLOW_THREADS;                                                    
      i_retval = virNodeGetInfo(virDomainGetConnect(domain), &nodeinfo);              
      LIBVIRT_END_ALLOW_THREADS;                                                      
      if (i_retval < 0)                                                               
          return VIR_PY_NONE;                                                         
                                                                                      
      LIBVIRT_BEGIN_ALLOW_THREADS;                                                    
      i_retval = virDomainGetInfo(domain, &dominfo);                                  
      LIBVIRT_END_ALLOW_THREADS;                                                      
      if (i_retval < 0)                                                               
          return VIR_PY_NONE;                                                         
                                                                                      
      if (VIR_ALLOC_N(cpuinfo, dominfo.nrVirtCpu) < 0)                                
          return VIR_PY_NONE;

  so we should add the None type checking to libvirt driver for the
  compatibility of old libvirt.

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


Follow ups

References