There is a chance to call conductor_api in the driver before the conductor_api is initialized

Bug #1156490 reported by YangLei
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Russell Bryant

Bug Description

Many functions use self._compute.conductor_api in class ComputeVirtAPI(virtapi.VirtAPI):
so during the driver loading (or the function __init__() of the driver), the driver has the chance to call conductor_api.
But conductor_api is initialized later than the driver loading, there will be some issue :
"ComputeManager object has no attribute 'conductor_api' "

https://github.com/openstack/nova/blob/master/nova/compute/manager.py

class ComputeManager(manager.SchedulerDependentManager):
    """Manages the running instances from creation to destruction."""

    RPC_API_VERSION = '2.27'

    def __init__(self, compute_driver=None, *args, **kwargs):
        """Load configuration options and connect to the hypervisor."""
        self.virtapi = ComputeVirtAPI(self)
        self.driver = driver.load_compute_driver(self.virtapi, compute_driver)
        ...
        self.conductor_api = conductor.API()
        ...

YangLei (yanglyy)
affects: marlin → nova
description: updated
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

YangLei,

Can you please upload some logs?

Chuck Short (zulcss)
Changed in nova:
status: New → Incomplete
Revision history for this message
YangLei (yanglyy) wrote :

I just review the code in function __init__() for classes ComputeManager and ComputeVirtAPI

I find that
        "self.conductor_api = conductor.API()"
is later than
        "self.virtapi = ComputeVirtAPI(self)
        self.driver = driver.load_compute_driver(self.virtapi, compute_driver)"

so the driver __init__() function has a chance to use conductor_api which is not initialized at this time.

functions use conductor_api e.g. :

class ComputeVirtAPI(virtapi.VirtAPI):
    def __init__(self, compute):
        super(ComputeVirtAPI, self).__init__()
        self._compute = compute

    def instance_get_by_uuid(self, context, instance_uuid):
        return self._compute.conductor_api.instance_get_by_uuid(
            context, instance_uuid)

    def instance_get_all_by_host(self, context, host):
        return self._compute.conductor_api.instance_get_all_by_host(
            context, host)

Changed in nova:
status: Incomplete → New
Changed in nova:
assignee: nobody → Russell Bryant (russellb)
status: New → Confirmed
importance: Undecided → High
tags: added: grizzly-backport-potential
tags: added: grizzly-rc-potential
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/25044

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

Reviewed: https://review.openstack.org/25044
Committed: http://github.com/openstack/nova/commit/9075069098e32b47bd5011e2653a23b61c18d4a3
Submitter: Jenkins
Branch: master

commit 9075069098e32b47bd5011e2653a23b61c18d4a3
Author: Russell Bryant <email address hidden>
Date: Thu Mar 21 15:08:18 2013 -0400

    Initialize compute manager before loading driver.

    The compute virt API uses the conductor API instance on the compute
    manager. Make sure the compute manager has been fully initialized
    before loading the driver and passing it the virtapi instance. This
    prevents the possibility of the driver calling back into the compute
    manager and using something not initialized yet, such as the conductor
    API in the case of this bug.

    This patch also moves initialization of a member variable up above
    super(), where the rest of the initialization is. There doesn't appear
    to be a reason for needing to have it at the end.

    Fix bug 1156490.

    Change-Id: I19684f24d590201d135336107425c2be2f74c83e

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → grizzly-rc2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (milestone-proposed)

Fix proposed to branch: milestone-proposed
Review: https://review.openstack.org/25274

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

Reviewed: https://review.openstack.org/25274
Committed: http://github.com/openstack/nova/commit/8cab8ed7294c776a18e560a0c89f4e1ae18c2d46
Submitter: Jenkins
Branch: milestone-proposed

commit 8cab8ed7294c776a18e560a0c89f4e1ae18c2d46
Author: Russell Bryant <email address hidden>
Date: Thu Mar 21 15:08:18 2013 -0400

    Initialize compute manager before loading driver.

    The compute virt API uses the conductor API instance on the compute
    manager. Make sure the compute manager has been fully initialized
    before loading the driver and passing it the virtapi instance. This
    prevents the possibility of the driver calling back into the compute
    manager and using something not initialized yet, such as the conductor
    API in the case of this bug.

    This patch also moves initialization of a member variable up above
    super(), where the rest of the initialization is. There doesn't appear
    to be a reason for needing to have it at the end.

    Fix bug 1156490.

    Change-Id: I19684f24d590201d135336107425c2be2f74c83e
    (cherry picked from commit 9075069098e32b47bd5011e2653a23b61c18d4a3)

Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-rc2 → 2013.1
Alan Pevec (apevec)
tags: removed: grizzly-backport-potential grizzly-rc-potential
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.