← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1759792] Re: [Testing] Compute nodes are registered to only one cell database regardless of their cells

 

Reviewed:  https://review.openstack.org/558160
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=6a06fd28c285786767c0af93149c32aa61846ff9
Submitter: Zuul
Branch:    master

commit 6a06fd28c285786767c0af93149c32aa61846ff9
Author: Takashi NATSUME <natsume.takashi@xxxxxxxxxxxxx>
Date:   Mon Apr 2 11:55:53 2018 +0900

    Fix the request context in ServiceFixture
    
    Multiple cells are not considered in ServiceFixture.
    So all compute nodes are registered to only one cell (cell1)
    database regardless of their cells.
    So change the ServiceFixture to use a request context
    for the cell where the service runs.
    
    Change-Id: I6e940518c6ec27c02c714db6c124eb88c72214ab
    Closes-Bug: #1759792


** Changed in: nova
       Status: In Progress => Fix Released

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

Title:
  [Testing] Compute nodes are registered to only one cell database
  regardless of their cells

Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  The nova processes for functional tests are started by the 'start_service' method of the 'TestCase' class in nova/test.py.
  A cell can be specified to run a process in the cell.

  https://github.com/openstack/nova/blob/00b19c73cfc72a79ab5ae4830a25dd53476a3b08/nova/test.py#L409-L427

  -------------------------------------------------------------------------------
      def start_service(self, name, host=None, **kwargs):
          if name == 'compute' and self.USES_DB:
              # NOTE(danms): We need to create the HostMapping first, because
              # otherwise we'll fail to update the scheduler while running
              # the compute node startup routines below.
              ctxt = context.get_context()
              cell = self.cell_mappings[kwargs.pop('cell', CELL1_NAME)]  <===
              hm = objects.HostMapping(context=ctxt,
                                       host=host or name,
                                       cell_mapping=cell)  <===
              hm.create()
              self.host_mappings[hm.host] = hm
              if host is not None:
                  # Make sure that CONF.host is relevant to the right hostname
                  self.useFixture(nova_fixtures.ConfPatcher(host=host))
          svc = self.useFixture(
              nova_fixtures.ServiceFixture(name, host, **kwargs))

          return svc.service
  -------------------------------------------------------------------------------

  But multiple cells are not considered in ServiceFixture.
  So all compute nodes are registered to only one cell (cell1) database regardless of their cells.

  The nova.context.get_admin_context() is called in the inside of self.service.start().
  It returns a context that is not aware of its cell.
  So the compute node is registered to only one cell (cell1) database regardless of its cell.

  https://github.com/openstack/nova/blob/00b19c73cfc72a79ab5ae4830a25dd53476a3b08/nova/tests/fixtures.py#L65-L82

  -------------------------------------------------------------------------------
  class ServiceFixture(fixtures.Fixture):
      """Run a service as a test fixture."""

      def __init__(self, name, host=None, **kwargs):
          name = name
          # If not otherwise specified, the host will default to the
          # name of the service. Some things like aggregates care that
          # this is stable.
          host = host or name
          kwargs.setdefault('host', host)
          kwargs.setdefault('binary', 'nova-%s' % name)
          self.kwargs = kwargs

      def setUp(self):
          super(ServiceFixture, self).setUp()
          self.service = service.Service.create(**self.kwargs)
          self.service.start()  <===
          self.addCleanup(self.service.kill)
  -------------------------------------------------------------------------------

  Environment
  -----------

  nova master (commit 00b19c73cfc72a79ab5ae4830a25dd53476a3b08)

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


References