PciDevTracker passes context module instead of instance

Bug #1408480 reported by Ed Leafe
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Ed Leafe
Juno
Fix Released
High
Nikola Đipanov

Bug Description

Currently, the code in the PciDevTracker.__init__() method of nova/pci/manager.py reads:

```
    def __init__(self, node_id=None):
        """Create a pci device tracker.

        If a node_id is passed in, it will fetch pci devices information
        from database, otherwise, it will create an empty devices list
        and the resource tracker will update the node_id information later.
        """

        super(PciDevTracker, self).__init__()
        self.stale = {}
        self.node_id = node_id
        self.stats = stats.PciDeviceStats()
        if node_id:
            self.pci_devs = list(
                objects.PciDeviceList.get_by_compute_node(context, node_id))
        else:
            self.pci_devs = []
        self._initial_instance_usage()
```

The problem is that in the call to `objects.PciDeviceList.get_by_compute_node(context, node_id)`, there is no local value for the 'context' parameter, so as a result, the context module defined in the imports is what is passed.

Instead, the parameter should be changed to `context.get_admin_context()`.

Ed Leafe (ed-leafe)
Changed in nova:
assignee: nobody → Ed Leafe (ed-leafe)
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/145619

Changed in nova:
status: New → In Progress
Changed in nova:
importance: Undecided → Low
tags: added: pci-passthrough
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/145619
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=50ee9dd76e8955dd57e5a7318be023c76c462f67
Submitter: Jenkins
Branch: master

commit 50ee9dd76e8955dd57e5a7318be023c76c462f67
Author: EdLeafe <email address hidden>
Date: Mon Jan 12 15:56:21 2015 +0000

    Pass correct context to get_by_compute_node()

    A recent change to the PciDevTracker class allowed for the passing of
    the compute node ID to the __init__() method, where
    PciDevsList.get_by_compute_node() was called with a 'context' parameter,
    which wasn't defined, resulting in the imported context module being
    passed instead.

    This change requires that the context be passed in to the __init__() for
    the PciDevTracker class, and that that be used to create the
    PciDevsList. The existing import of the context module is no longer
    needed in the pci/manager.py file, so the conflict is no longer a
    problem. The only place in the code that currently instantiates a
    PciDevTracker object is in the ResourceTracker, so that has been updated
    to pass in the context. A unit test to check for context has also been
    added.

    Change-Id: Id136eabacb00e4381c03f12d8484fc90a5eb48b1
    Closes-Bug: #1408480

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-3
status: Fix Committed → Fix Released
tags: added: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/173225

Revision history for this message
Alan Pevec (apevec) wrote :

While this is Low by itself, it is required for Juno backport of bug 1415768

tags: removed: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/juno)

Reviewed: https://review.openstack.org/173225
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=cfce73b36a3afe4e8be889faf3f5ec78bd19c0c7
Submitter: Jenkins
Branch: stable/juno

commit cfce73b36a3afe4e8be889faf3f5ec78bd19c0c7
Author: EdLeafe <email address hidden>
Date: Mon Jan 12 15:56:21 2015 +0000

    Pass correct context to get_by_compute_node()

    A recent change to the PciDevTracker class allowed for the passing of
    the compute node ID to the __init__() method, where
    PciDevsList.get_by_compute_node() was called with a 'context' parameter,
    which wasn't defined, resulting in the imported context module being
    passed instead.

    This change requires that the context be passed in to the __init__() for
    the PciDevTracker class, and that that be used to create the
    PciDevsList. The existing import of the context module is no longer
    needed in the pci/manager.py file, so the conflict is no longer a
    problem. The only place in the code that currently instantiates a
    PciDevTracker object is in the ResourceTracker, so that has been updated
    to pass in the context. A unit test to check for context has also been
    added.

    (cherry picked from commit 50ee9dd76e8955dd57e5a7318be023c76c462f67)

    Conflicts:
     nova/compute/resource_tracker.py
     nova/tests/pci/test_pci_manager.py

    Closes-Bug: #1408480
    Change-Id: Id136eabacb00e4381c03f12d8484fc90a5eb48b1

Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-3 → 2015.1.0
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.