[Bug 1314677] Re: nova-cells fails when using JSON file to store cell information

OpenStack Infra 1314677 at bugs.launchpad.net
Fri Oct 24 08:08:28 UTC 2014


Reviewed:  https://review.openstack.org/124811
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=bfeae680bc0632e0129b647d45e4b80328a33535
Submitter: Jenkins
Branch:    stable/icehouse

commit bfeae680bc0632e0129b647d45e4b80328a33535
Author: Liam Young <liam.young at canonical.com>
Date:   Tue Jul 22 16:25:00 2014 +0100

    Fix CellStateManagerFile init to failure
    
    Currently, specifying a cells_config file in nova.conf causes
    CellStateManager to fail and in turn stops the nova-cells service from
    starting. The reason is that CellsManager creates an instance of
    CellStateManager with no arguments. CellStateManager __new__ runs and
    creates an instance of CellStateManagerFile which runs __new__ and
    __init__ with cell_state_cls and cells_config_path set. At this point
    __new__ returns CellStateManagerFile and the new instance's __init__
    method is invoked (CellStateManagerFile.__init__) with the original
    arguments (there weren't any) which then results in:
    2014-04-29 11:52:05.240 16759 TRACE nova self.state_manager =
    cell_state_manager()
    2014-04-29 11:52:05.240 16759 TRACE nova TypeError: __init__() takes
    exactly 3 arguments (1 given)
    
    It seems reasonable for CellStateManagerFile to derive the
    cells_config_path info for itself so I have updated the code with that
    change and added unit tests to catch this bug and to check that the
    correct managers are still returned
    
    Closes-Bug: #1314677
    (cherry picked from commit 695191fa89387d96e60120ff32965493c844e7f5)
    
    Conflicts:
    	nova/tests/cells/test_cells_state_manager.py
    
    Change-Id: I9021640515142a3ca95c2d9e7b03e19b529bc175


** Tags added: in-stable-icehouse

-- 
You received this bug notification because you are a member of Ubuntu
Sponsors Team, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/1314677

Title:
  nova-cells fails when using JSON file to store cell information

Status in OpenStack Compute (Nova):
  Fix Released
Status in “nova” package in Ubuntu:
  Fix Released
Status in “nova” source package in Trusty:
  Fix Released

Bug description:
  As recommended in http://docs.openstack.org/havana/config-
  reference/content/section_compute-cells.html#cell-config-optional-json
  I'm creating the nova-cells config with the cell information stored in
  a json file. However, when I do this nova-cells fails to start with
  this error in the logs:

  2014-04-29 11:52:05.240 16759 CRITICAL nova [-] __init__() takes exactly 3 arguments (1 given)
  2014-04-29 11:52:05.240 16759 TRACE nova Traceback (most recent call last):
  2014-04-29 11:52:05.240 16759 TRACE nova   File "/usr/bin/nova-cells", line 10, in <module>
  2014-04-29 11:52:05.240 16759 TRACE nova     sys.exit(main())
  2014-04-29 11:52:05.240 16759 TRACE nova   File "/usr/lib/python2.7/dist-packages/nova/cmd/cells.py", line 40, in main
  2014-04-29 11:52:05.240 16759 TRACE nova     manager=CONF.cells.manager)
  2014-04-29 11:52:05.240 16759 TRACE nova   File "/usr/lib/python2.7/dist-packages/nova/service.py", line 257, in create
  2014-04-29 11:52:05.240 16759 TRACE nova     db_allowed=db_allowed)
  2014-04-29 11:52:05.240 16759 TRACE nova   File "/usr/lib/python2.7/dist-packages/nova/service.py", line 139, in __init__
  2014-04-29 11:52:05.240 16759 TRACE nova     self.manager = manager_class(host=self.host, *args, **kwargs)
  2014-04-29 11:52:05.240 16759 TRACE nova   File "/usr/lib/python2.7/dist-packages/nova/cells/manager.py", line 87, in __init__
  2014-04-29 11:52:05.240 16759 TRACE nova     self.state_manager = cell_state_manager()
  2014-04-29 11:52:05.240 16759 TRACE nova TypeError: __init__() takes exactly 3 arguments (1 given)

  
  I have had a dig into the code and it appears that CellsManager creates an instance of CellStateManager with no arguments. CellStateManager __new__ runs and creates an instance of CellStateManagerFile which runs __new__ and __init__ with cell_state_cls and cells_config_path set. At this point __new__ returns CellStateManagerFile and the new instance's __init__() method is invoked (CellStateManagerFile.__init__) with the original arguments (there weren't any) which then results in the stack trace.

  It seems reasonable for CellStateManagerFile to derive the
  cells_config_path info for itself so I've patched it locally with

  === modified file 'state.py'
  --- state.py	2014-04-30 15:10:16 +0000
  +++ state.py	2014-04-30 15:10:26 +0000
  @@ -155,7 +155,7 @@
               config_path = CONF.find_file(cells_config)
               if not config_path:
                   raise cfg.ConfigFilesNotFoundError(config_files=[cells_config])
  -            return CellStateManagerFile(cell_state_cls, config_path)
  +            return CellStateManagerFile(cell_state_cls)
   
           return CellStateManagerDB(cell_state_cls)
   
  @@ -450,7 +450,9 @@
   
   
   class CellStateManagerFile(CellStateManager):
  -    def __init__(self, cell_state_cls, cells_config_path):
  +    def __init__(self, cell_state_cls=None):
  +        cells_config = CONF.cells.cells_config
  +        cells_config_path = CONF.find_file(cells_config)
           self.cells_config_path = cells_config_path
           super(CellStateManagerFile, self).__init__(cell_state_cls)
   

  
  Ubuntu: 14.04
  nova-cells: 1:2014.1-0ubuntu1

  nova.conf:

  [DEFAULT]
  dhcpbridge_flagfile=/etc/nova/nova.conf
  dhcpbridge=/usr/bin/nova-dhcpbridge
  logdir=/var/log/nova
  state_path=/var/lib/nova
  lock_path=/var/lock/nova
  force_dhcp_release=True
  iscsi_helper=tgtadm
  libvirt_use_virtio_for_bridges=True
  connection_type=libvirt
  root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
  verbose=True
  ec2_private_dns_show_ip=True
  api_paste_config=/etc/nova/api-paste.ini
  volumes_path=/var/lib/nova/volumes
  enabled_apis=ec2,osapi_compute,metadata
  auth_strategy=keystone
  compute_driver=libvirt.LibvirtDriver
  quota_driver=nova.quota.NoopQuotaDriver

  
  [cells]
  enable=True
  name=cell
  cell_type=compute
  cells_config=/etc/nova/cells.json

  
  cells.json: 
  {
      "parent": {
          "name": "parent",
          "api_url": "http://api.example.com:8774",
          "transport_url": "rabbit://rabbit.example.com",
          "weight_offset": 0.0,
          "weight_scale": 1.0,
          "is_parent": true
      }
  }

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



More information about the Ubuntu-sponsors mailing list